am 73abc2ea: Merge change I9c6e1f90 into eclair-mr2

Merge commit '73abc2ea4c4e23a5561bbf769b4b74d1faa38e4a' into eclair-mr2-plus-aosp

* commit '73abc2ea4c4e23a5561bbf769b4b74d1faa38e4a':
  Initial check in of stagefright software AAC decoder based on PV source code.
This commit is contained in:
Andreas Huber
2009-12-07 11:06:20 -08:00
committed by Android Git Automerger
342 changed files with 81958 additions and 0 deletions

View File

@@ -50,6 +50,13 @@ LOCAL_SHARED_LIBRARIES := \
libcutils \
libui
ifeq ($(BUILD_WITH_FULL_STAGEFRIGHT),true)
LOCAL_STATIC_LIBRARIES := \
libstagefright_aacdec
endif
ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true)
LOCAL_LDLIBS += -lpthread
endif

View File

@@ -18,6 +18,7 @@
#define LOG_TAG "OMXCodec"
#include <utils/Log.h>
#include "include/AACDecoder.h"
#include "include/ESDS.h"
#include <binder/IServiceManager.h>
@@ -284,6 +285,10 @@ sp<MediaSource> OMXCodec::Create(
bool success = meta->findCString(kKeyMIMEType, &mime);
CHECK(success);
if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC)) {
return new AACDecoder(source);
}
Vector<String8> matchingCodecs;
findMatchingCodecs(
mime, createEncoder, matchComponentName, flags, &matchingCodecs);

View File

@@ -0,0 +1,8 @@
ifeq ($(BUILD_WITH_FULL_STAGEFRIGHT),true)
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
include $(call all-makefiles-under,$(LOCAL_PATH))
endif

View File

@@ -0,0 +1,202 @@
#include "AACDecoder.h"
#include "../../include/ESDS.h"
#include "pvmp4audiodecoder_api.h"
#include <media/stagefright/MediaBufferGroup.h>
#include <media/stagefright/MediaDebug.h>
#include <media/stagefright/MediaDefs.h>
#include <media/stagefright/MetaData.h>
namespace android {
AACDecoder::AACDecoder(const sp<MediaSource> &source)
: mSource(source),
mStarted(false),
mBufferGroup(NULL),
mConfig(new tPVMP4AudioDecoderExternal),
mDecoderBuf(NULL),
mLastSeekTimeUs(0),
mNumSamplesOutput(0),
mInputBuffer(NULL) {
}
AACDecoder::~AACDecoder() {
if (mStarted) {
stop();
}
delete mConfig;
mConfig = NULL;
}
status_t AACDecoder::start(MetaData *params) {
CHECK(!mStarted);
mBufferGroup = new MediaBufferGroup;
mBufferGroup->add_buffer(new MediaBuffer(2048 * 2));
mConfig->outputFormat = OUTPUTFORMAT_16PCM_INTERLEAVED;
mConfig->aacPlusUpsamplingFactor = 0;
mConfig->aacPlusEnabled = false;
int32_t numChannels;
CHECK(mSource->getFormat()->findInt32(kKeyChannelCount, &numChannels));
mConfig->desiredChannels = numChannels;
UInt32 memRequirements = PVMP4AudioDecoderGetMemRequirements();
mDecoderBuf = malloc(memRequirements);
CHECK_EQ(PVMP4AudioDecoderInitLibrary(mConfig, mDecoderBuf),
MP4AUDEC_SUCCESS);
uint32_t type;
const void *data;
size_t size;
if (mSource->getFormat()->findData(kKeyESDS, &type, &data, &size)) {
ESDS esds((const char *)data, size);
CHECK_EQ(esds.InitCheck(), OK);
const void *codec_specific_data;
size_t codec_specific_data_size;
esds.getCodecSpecificInfo(
&codec_specific_data, &codec_specific_data_size);
mConfig->pInputBuffer = (UChar *)codec_specific_data;
mConfig->inputBufferCurrentLength = codec_specific_data_size;
mConfig->inputBufferMaxLength = 0;
mConfig->inputBufferUsedLength = 0;
mConfig->remainderBits = 0;
mConfig->pOutputBuffer = NULL;
mConfig->pOutputBuffer_plus = NULL;
mConfig->repositionFlag = false;
CHECK_EQ(PVMP4AudioDecoderConfig(mConfig, mDecoderBuf),
MP4AUDEC_SUCCESS);
}
mSource->start();
mLastSeekTimeUs = 0;
mNumSamplesOutput = 0;
mStarted = true;
return OK;
}
status_t AACDecoder::stop() {
CHECK(mStarted);
if (mInputBuffer) {
mInputBuffer->release();
mInputBuffer = NULL;
}
free(mDecoderBuf);
mDecoderBuf = NULL;
delete mBufferGroup;
mBufferGroup = NULL;
mSource->stop();
mStarted = false;
return OK;
}
sp<MetaData> AACDecoder::getFormat() {
sp<MetaData> srcFormat = mSource->getFormat();
int32_t numChannels;
int32_t sampleRate;
CHECK(srcFormat->findInt32(kKeyChannelCount, &numChannels));
CHECK(srcFormat->findInt32(kKeySampleRate, &sampleRate));
sp<MetaData> meta = new MetaData;
meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_RAW);
meta->setInt32(kKeyChannelCount, numChannels);
meta->setInt32(kKeySampleRate, sampleRate);
return meta;
}
status_t AACDecoder::read(
MediaBuffer **out, const ReadOptions *options) {
status_t err;
*out = NULL;
int64_t seekTimeUs;
if (options && options->getSeekTo(&seekTimeUs)) {
CHECK(seekTimeUs >= 0);
mNumSamplesOutput = 0;
if (mInputBuffer) {
mInputBuffer->release();
mInputBuffer = NULL;
}
} else {
seekTimeUs = -1;
}
if (mInputBuffer == NULL) {
err = mSource->read(&mInputBuffer, options);
if (err != OK) {
return err;
}
if (seekTimeUs >= 0) {
CHECK(mInputBuffer->meta_data()->findInt64(
kKeyTime, &mLastSeekTimeUs));
mNumSamplesOutput = 0;
}
}
MediaBuffer *buffer;
CHECK_EQ(mBufferGroup->acquire_buffer(&buffer), OK);
mConfig->pInputBuffer =
(UChar *)mInputBuffer->data() + mInputBuffer->range_offset();
mConfig->inputBufferCurrentLength = mInputBuffer->range_length();
mConfig->inputBufferMaxLength = 0;
mConfig->inputBufferUsedLength = 0;
mConfig->remainderBits = 0;
mConfig->pOutputBuffer = static_cast<Int16 *>(buffer->data());
mConfig->pOutputBuffer_plus = NULL;
mConfig->repositionFlag = false;
CHECK_EQ(PVMP4AudioDecodeFrame(mConfig, mDecoderBuf), MP4AUDEC_SUCCESS);
buffer->set_range(
0, mConfig->frameLength * sizeof(int16_t) * mConfig->desiredChannels);
mInputBuffer->set_range(
mInputBuffer->range_offset() + mConfig->inputBufferUsedLength,
mInputBuffer->range_length() - mConfig->inputBufferUsedLength);
if (mInputBuffer->range_length() == 0) {
mInputBuffer->release();
mInputBuffer = NULL;
}
buffer->meta_data()->setInt64(
kKeyTime,
mLastSeekTimeUs
+ (mNumSamplesOutput * 1000000) / mConfig->samplingRate);
mNumSamplesOutput += mConfig->frameLength;
*out = buffer;
return OK;
}
} // namespace android

View File

@@ -0,0 +1,158 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
analysis_sub_band.cpp \
apply_ms_synt.cpp \
apply_tns.cpp \
buf_getbits.cpp \
byte_align.cpp \
calc_auto_corr.cpp \
calc_gsfb_table.cpp \
calc_sbr_anafilterbank.cpp \
calc_sbr_envelope.cpp \
calc_sbr_synfilterbank.cpp \
check_crc.cpp \
dct16.cpp \
dct64.cpp \
decode_huff_cw_binary.cpp \
decode_noise_floorlevels.cpp \
deinterleave.cpp \
digit_reversal_tables.cpp \
dst16.cpp \
dst32.cpp \
dst8.cpp \
esc_iquant_scaling.cpp \
extractframeinfo.cpp \
fft_rx4_long.cpp \
fft_rx4_short.cpp \
fft_rx4_tables_fxp.cpp \
find_adts_syncword.cpp \
fwd_long_complex_rot.cpp \
fwd_short_complex_rot.cpp \
gen_rand_vector.cpp \
get_adif_header.cpp \
get_adts_header.cpp \
get_audio_specific_config.cpp \
get_dse.cpp \
get_ele_list.cpp \
get_ga_specific_config.cpp \
get_ics_info.cpp \
get_prog_config.cpp \
get_pulse_data.cpp \
get_sbr_bitstream.cpp \
get_sbr_startfreq.cpp \
get_sbr_stopfreq.cpp \
get_tns.cpp \
getfill.cpp \
getgroup.cpp \
getics.cpp \
getmask.cpp \
hcbtables_binary.cpp \
huffcb.cpp \
huffdecode.cpp \
hufffac.cpp \
huffspec_fxp.cpp \
idct16.cpp \
idct32.cpp \
idct8.cpp \
imdct_fxp.cpp \
infoinit.cpp \
init_sbr_dec.cpp \
intensity_right.cpp \
inv_long_complex_rot.cpp \
inv_short_complex_rot.cpp \
iquant_table.cpp \
long_term_prediction.cpp \
long_term_synthesis.cpp \
lt_decode.cpp \
mdct_fxp.cpp \
mdct_tables_fxp.cpp \
mdst.cpp \
mix_radix_fft.cpp \
ms_synt.cpp \
pns_corr.cpp \
pns_intensity_right.cpp \
pns_left.cpp \
ps_all_pass_filter_coeff.cpp \
ps_all_pass_fract_delay_filter.cpp \
ps_allocate_decoder.cpp \
ps_applied.cpp \
ps_bstr_decoding.cpp \
ps_channel_filtering.cpp \
ps_decode_bs_utils.cpp \
ps_decorrelate.cpp \
ps_fft_rx8.cpp \
ps_hybrid_analysis.cpp \
ps_hybrid_filter_bank_allocation.cpp \
ps_hybrid_synthesis.cpp \
ps_init_stereo_mixing.cpp \
ps_pwr_transient_detection.cpp \
ps_read_data.cpp \
ps_stereo_processing.cpp \
pulse_nc.cpp \
pv_div.cpp \
pv_log2.cpp \
pv_normalize.cpp \
pv_pow2.cpp \
pv_sine.cpp \
pv_sqrt.cpp \
pvmp4audiodecoderconfig.cpp \
pvmp4audiodecoderframe.cpp \
pvmp4audiodecodergetmemrequirements.cpp \
pvmp4audiodecoderinitlibrary.cpp \
pvmp4audiodecoderresetbuffer.cpp \
q_normalize.cpp \
qmf_filterbank_coeff.cpp \
sbr_aliasing_reduction.cpp \
sbr_applied.cpp \
sbr_code_book_envlevel.cpp \
sbr_crc_check.cpp \
sbr_create_limiter_bands.cpp \
sbr_dec.cpp \
sbr_decode_envelope.cpp \
sbr_decode_huff_cw.cpp \
sbr_downsample_lo_res.cpp \
sbr_envelope_calc_tbl.cpp \
sbr_envelope_unmapping.cpp \
sbr_extract_extended_data.cpp \
sbr_find_start_andstop_band.cpp \
sbr_generate_high_freq.cpp \
sbr_get_additional_data.cpp \
sbr_get_cpe.cpp \
sbr_get_dir_control_data.cpp \
sbr_get_envelope.cpp \
sbr_get_header_data.cpp \
sbr_get_noise_floor_data.cpp \
sbr_get_sce.cpp \
sbr_inv_filt_levelemphasis.cpp \
sbr_open.cpp \
sbr_read_data.cpp \
sbr_requantize_envelope_data.cpp \
sbr_reset_dec.cpp \
sbr_update_freq_scale.cpp \
set_mc_info.cpp \
sfb.cpp \
shellsort.cpp \
synthesis_sub_band.cpp \
tns_ar_filter.cpp \
tns_decode_coef.cpp \
tns_inv_filter.cpp \
trans4m_freq_2_time_fxp.cpp \
trans4m_time_2_freq_fxp.cpp \
unpack_idx.cpp \
window_tables_fxp.cpp \
pvmp4setaudioconfig.cpp \
AACDecoder.cpp
LOCAL_CFLAGS := -DAAC_PLUS -DHQ_SBR -DPARAMETRICSTEREO -DOSCL_IMPORT_REF= -DOSCL_EXPORT_REF= -DOSCL_UNUSED_ARG=
LOCAL_C_INCLUDES := frameworks/base/media/libstagefright/include
LOCAL_SHARED_LIBRARIES := \
libstagefright \
libutils
LOCAL_MODULE := libstagefright_aacdec
include $(BUILD_STATIC_LIBRARY)

View File

@@ -0,0 +1,50 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: aac_mem_funcs.h
Funtions:
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#include <string.h>
#ifndef AAC_MEM_FUNCS_H
#define AAC_MEM_FUNCS_H
#define pv_memset(to, c, n) memset(to, c, n)
#define pv_memcpy(to, from, n) memcpy(to, from, n)
#define pv_memmove(to, from, n) memmove(to, from, n)
#define pv_memcmp(p, q, n) memcmp(p, q, n)
#endif

View File

@@ -0,0 +1,289 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: analysis_sub_band.c
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Int32 vec[], Input vector, 32-bit
const Int32 *cosTerms, Cosine Terms
Int maxbands number of bands used
Int32 *scratch_mem Scratch memory
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
Implement root squared of a number
------------------------------------------------------------------------------
REQUIREMENTS
------------------------------------------------------------------------------
REFERENCES
------------------------------------------------------------------------------
PSEUDO-CODE
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#ifdef AAC_PLUS
#include "analysis_sub_band.h"
#include "dst32.h"
#include "idct32.h"
#include "mdst.h"
#include "aac_mem_funcs.h"
#include "pv_audio_type_defs.h"
#include "fxp_mul32.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
#ifdef HQ_SBR
const Int32 exp_1_5_phi[32] =
{
0x7FEA04B6, 0x7F380E1C, 0x7DD6176E, 0x7BC6209F,
0x790A29A4, 0x75A6326E, 0x719E3AF3, 0x6CF94326,
0x67BD4AFB, 0x61F15269, 0x5B9D5964, 0x54CA5FE4,
0x4D8165DE, 0x45CD6B4B, 0x3DB87023, 0x354E7460,
0x2C9977FB, 0x23A77AEF, 0x1A837D3A, 0x113A7ED6,
0x07D97FC2, 0xFE6E7FFE, 0xF5057F87, 0xEBAB7E60,
0xE26D7C89, 0xD9587A06, 0xD07976D9, 0xC7DB7308,
0xBF8C6E97, 0xB796698C, 0xB00563EF, 0xA8E25DC8,
};
#endif
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
void analysis_sub_band_LC(Int32 vec[64],
Int32 cosine_total[],
Int32 maxBand,
Int32 scratch_mem[][64])
{
Int32 i;
Int32 *cosine_term = &scratch_mem[0][0];
Int32 *sine_term = &scratch_mem[0][32];
Int32 *pt_cos_t;
Int32 *pt_vec = &vec[0];
Int32 *pt_vec_32 = &vec[32];
Int32 *pt_cos = cosine_term;
Int32 *pt_sin = sine_term;
for (i = 8; i != 0; i--)
{
Int32 tmp1 = *(pt_vec_32++);
Int32 tmp3 = *(pt_vec_32++);
Int32 tmp2 = *(pt_vec++);
Int32 tmp4 = *(pt_vec++);
*(pt_cos++) = (tmp1 - tmp2) >> 1;
*(pt_cos++) = (tmp3 - tmp4) >> 1;
*(pt_sin++) = (tmp1 + tmp2);
*(pt_sin++) = (tmp3 + tmp4);
tmp1 = *(pt_vec_32++);
tmp3 = *(pt_vec_32++);
tmp2 = *(pt_vec++);
tmp4 = *(pt_vec++);
*(pt_cos++) = (tmp1 - tmp2) >> 1;
*(pt_cos++) = (tmp3 - tmp4) >> 1;
*(pt_sin++) = (tmp1 + tmp2);
*(pt_sin++) = (tmp3 + tmp4);
}
idct_32(cosine_term, scratch_mem[1]);
dst_32(sine_term, scratch_mem[1]);
pt_cos = cosine_term;
pt_sin = sine_term;
pt_cos_t = cosine_total;
for (i = 0; i < maxBand; i += 4)
{
*(pt_cos_t++) = (*(pt_cos++) + *(pt_sin++));
*(pt_cos_t++) = (-*(pt_cos++) + *(pt_sin++));
*(pt_cos_t++) = (-*(pt_cos++) - *(pt_sin++));
*(pt_cos_t++) = (*(pt_cos++) - *(pt_sin++));
}
pt_cos_t = &cosine_total[maxBand];
for (i = (32 - maxBand); i != 0; i--)
{
*(pt_cos_t++) = 0;
}
}
#ifdef HQ_SBR
void analysis_sub_band(Int32 vec[64],
Int32 cosine_total[],
Int32 sine_total[],
Int32 maxBand,
Int32 scratch_mem[][64])
{
Int32 i;
Int32 *sine_term1 = &scratch_mem[0][0];
Int32 *sine_term2 = &scratch_mem[0][32];
Int32 temp1;
Int32 temp2;
Int32 temp3;
Int32 temp4;
const Int32 *pt_exp;
Int32 exp_1_5;
Int32 *pt_vec = &vec[0];
Int32 *pt_vec_32 = &vec[32];
Int32 *pt_cos1 = pt_vec;
Int32 *pt_sin1 = sine_term1;
Int32 *pt_cos2 = pt_vec_32;
Int32 *pt_sin2 = sine_term2;
pv_memcpy(sine_term1, vec, 64*sizeof(*vec));
mdst_32(sine_term1, scratch_mem[1]);
mdst_32(sine_term2, scratch_mem[1]);
mdct_32(&vec[ 0]);
mdct_32(&vec[32]);
pt_cos1 = &vec[ 0];
pt_cos2 = &vec[32];
pt_sin1 = sine_term1;
pt_sin2 = sine_term2;
pt_vec = cosine_total;
pt_vec_32 = sine_total;
pt_exp = exp_1_5_phi;
temp3 = (*(pt_cos1++) - *(pt_sin2++));
temp4 = (*(pt_sin1++) + *(pt_cos2++));
for (i = 0; i < maxBand; i += 2)
{
exp_1_5 = *(pt_exp++);
temp1 = cmplx_mul32_by_16(temp3, temp4, exp_1_5);
temp2 = cmplx_mul32_by_16(temp4, -temp3, exp_1_5);
*(pt_vec++) = shft_lft_1(temp1);
*(pt_vec_32++) = shft_lft_1(temp2);
temp3 = (*(pt_cos1++) + *(pt_sin2++));
temp4 = (*(pt_sin1++) - *(pt_cos2++));
exp_1_5 = *(pt_exp++);
temp1 = cmplx_mul32_by_16(temp3, temp4, exp_1_5);
temp2 = cmplx_mul32_by_16(temp4, -temp3, exp_1_5);
*(pt_vec++) = shft_lft_1(temp1);
*(pt_vec_32++) = shft_lft_1(temp2);
temp3 = (*(pt_cos1++) - *(pt_sin2++));
temp4 = (*(pt_sin1++) + *(pt_cos2++));
}
pt_cos1 = &cosine_total[maxBand]; /* in the chance that maxband is not even */
pt_sin1 = &sine_total[maxBand];
for (i = (32 - maxBand); i != 0; i--)
{
*(pt_cos1++) = 0;
*(pt_sin1++) = 0;
}
}
#endif
#endif

View File

@@ -0,0 +1,82 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./c/include/analysis_sub_band.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
------------------------------------------------------------------------------
*/
#ifndef ANALYSIS_SUB_BAND_H
#define ANALYSIS_SUB_BAND_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
{
#endif
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES AND SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
void analysis_sub_band_LC(Int32 vec[64],
Int32 cosine_total[],
Int32 maxBand,
Int32 scratch_mem[][64]);
#ifdef HQ_SBR
void analysis_sub_band(Int32 vec[64],
Int32 cosine_total[],
Int32 sine_total[],
Int32 maxBand,
Int32 scratch_mem[][64]);
#endif
#ifdef __cplusplus
}
#endif
#endif /* ANALYSIS_SUB_BAND_H */

View File

@@ -0,0 +1,454 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./src/apply_ms_synt.c
------------------------------------------------------------------------------
REVISION HISTORY
Description: Updated pseudocode to correct capitalized format for the IF
FOR and WHILE statements.
Description: Delete local variable start_indx, since it is never used.
Who: Date:
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Inputs:
pFrameInfo = Pointer to structure that holds information about each group.
(long block flag, number of windows, scalefactor bands
per group, etc.)
[const pFrameInfo * const]
group = Array that contains indexes of the
first window in the next group.
[const Int *, length 8]
mask_map = Array that denotes whether M/S stereo is turned on for
each grouped scalefactor band.
[const Int *, length MAX_SFB]
codebook_map = Array that denotes which Huffman codebook was used for
the encoding of each grouped scalefactor band.
[const Int *, length MAX_SFB]
coefLeft = Array containing the fixed-point spectral coefficients
for the left channel.
[Int32 *, length 1024]
coefRight = Array containing the fixed-point spectral coefficients
for the right channel.
[Int32 *, length 1024]
q_formatLeft = The Q-format for the left channel's fixed-point spectral
coefficients, on a per-scalefactor band, non-grouped basis.
[Int *, length MAX_SFB]
q_formatRight = The Q-format for the right channel's fixed-point spectral
coefficients, on a per-scalefactor band, non-grouped basis.
[Int *, length MAX_SFB]
Local Stores/Buffers/Pointers Needed:
None
Global Stores/Buffers/Pointers Needed:
None
Outputs:
None
Pointers and Buffers Modified:
coefLeft = Contains the new spectral information.
coefRight = Contains the new spectral information.
q_formatLeft = Q-format may be updated with changed to fixed-point
data in coefLeft.
q_formatRight = Q-format may be updated with changed to fixed-point
data in coefRight.
Local Stores Modified:
None
Global Stores Modified:
None
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
This function steps through all of the tools that are applied on a
scalefactor band basis.
The use of M/S stereo is checked for. For M/S decoding to take
place, ms_mask_map must be TRUE for that particular SFB, AND the Huffman
codebook used must be < NOISE_HCB.
------------------------------------------------------------------------------
REQUIREMENTS
------------------------------------------------------------------------------
REFERENCES
(1) ISO/IEC 14496-3:1999(E)
Part 3
Subpart 4.6.7.1 M/S stereo
Subpart 4.6.2 ScaleFactors
(2) MPEG-2 NBC Audio Decoder
"This software module was originally developed by AT&T, Dolby
Laboratories, Fraunhofer Gesellschaft IIS in the course of development
of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
3. This software module is an implementation of a part of one or more
MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
standards free license to this software module or modifications thereof
for use in hardware or software products claiming conformance to the
MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
module in hardware or software products are advised that this use may
infringe existing patents. The original developer of this software
module and his/her company, the subsequent editors and their companies,
and ISO/IEC have no liability for use of this software module or
modifications thereof in an implementation. Copyright is not released
for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
developer retains full right to use the code for his/her own purpose,
assign or donate the code to a third party and to inhibit third party
from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
This copyright notice must be included in all copies or derivative
works."
Copyright(c)1996.
------------------------------------------------------------------------------
PSEUDO-CODE
pCoefRight = coefRight;
pCoefLeft = coefLeft;
window_start = 0;
tot_sfb = 0;
coef_per_win = pFrameInfo->coef_per_win[0];
sfb_per_win = pFrameInfo->sfb_per_win[0];
DO
pBand = pFrameInfo->win_sfb_top[window_start];
partition = *(pGroup);
pGroup = pGroup + 1;
band_start = 0;
wins_in_group = (partition - window_start);
FOR (sfb = sfb_per_win; sfb > 0; sfb--)
band_stop = *(pBand);
pBand = pBand + 1;
codebook = *(pCodebookMap);
pCodebookMap = pCodebookMap + 1;
mask_enabled = *(pMaskMap);
pMaskMap = pMaskMap + 1;
IF (codebook < NOISE_HCB)
THEN
IF (mask_enabled != FALSE)
THEN
band_length = band_stop - band_start;
CALL
ms_synt(
wins_in_group,
coef_per_win,
sfb_per_win,
band_length,
&(pCoefLeft[band_start]),
&(pCoefRight[band_start]),
&(q_formatLeft[tot_sfb]),
&(q_formatRight[tot_sfb]) );
MODIFYING
&(pCoefLeft[band_start]),
&(pCoefRight[band_start]),
&(q_formatLeft[tot_sfb]),
&(q_formatRight[tot_sfb])
RETURNING
None
ENDIF
ENDIF
band_start = band_stop;
tot_sfb = tot_sfb + 1;
ENDFOR
pCoefRight = pCoefRight + coef_per_win * wins_in_group;
pCoefLeft = pCoefLeft + coef_per_win * wins_in_group;
wins_in_group = wins_in_group - 1;
tot_sfb = tot_sfb + sfb_per_win * wins_in_group;
window_start = partition;
WHILE (partition < pFrameInfo->num_win);
return;
------------------------------------------------------------------------------
RESOURCES USED
When the code is written for a specific target processor the
resources used should be documented below.
STACK USAGE: [stack count for this module] + [variable to represent
stack usage for each subroutine called]
where: [stack usage variable] = stack usage for [subroutine
name] (see [filename].ext)
DATA MEMORY USED: x words
PROGRAM MEMORY USED: x words
CLOCK CYCLES: [cycle count equation for this module] + [variable
used to represent cycle count for each subroutine
called]
where: [cycle count variable] = cycle count for [subroutine
name] (see [filename].ext)
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "apply_ms_synt.h"
#include "e_huffmanconst.h"
#include "ms_synt.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
void apply_ms_synt(
const FrameInfo * const pFrameInfo,
const Int group[],
const Bool mask_map[],
const Int codebook_map[],
Int32 coefLeft[],
Int32 coefRight[],
Int q_formatLeft[MAXBANDS],
Int q_formatRight[MAXBANDS])
{
Int32 *pCoefRight;
Int32 *pCoefLeft;
Int tot_sfb;
Int sfb;
Int band_length;
Int band_start;
Int band_stop;
Int coef_per_win;
Int codebook;
Int partition;
Int window_start;
Int sfb_per_win;
Int wins_in_group;
const Int16 *pBand;
const Int *pCodebookMap = codebook_map;
const Int *pGroup = group;
const Bool *pMaskMap = mask_map;
Bool mask_enabled;
pCoefRight = coefRight;
pCoefLeft = coefLeft;
window_start = 0;
tot_sfb = 0;
/*
* Each window in the frame should have the same number of coef's,
* so coef_per_win is constant in all the loops
*/
coef_per_win = pFrameInfo->coef_per_win[0];
/*
* Because the number of scalefactor bands per window should be
* constant for each frame, sfb_per_win can be determined outside
* of the loop.
*
* For 44.1 kHz sampling rate sfb_per_win = 14 for short windows
* sfb_per_win = 49 for long windows
*/
sfb_per_win = pFrameInfo->sfb_per_win[0];
do
{
pBand = pFrameInfo->win_sfb_top[window_start];
/*
* Partition is equal to the first window in the next group
*
* { Group 0 }{ Group 1 }{ Group 2 }{Group 3}
* [win 0][win 1][win 2][win 3][win 4][win 5][win 6][win 7]
*
* pGroup[0] = 2
* pGroup[1] = 5
* pGroup[2] = 7
* pGroup[3] = 8
*/
partition = *(pGroup++);
band_start = 0;
wins_in_group = (partition - window_start);
for (sfb = sfb_per_win; sfb > 0; sfb--)
{
/* band is offset table, band_stop is last coef in band */
band_stop = *(pBand++);
codebook = *(pCodebookMap++);
mask_enabled = *(pMaskMap++);
/*
* When a codebook < NOISE_HCB is found, apply M/S to that
* scalefactorband.
*
* Example... sfb[3] == NOISE_HCB
*
* [ Group 1 ]
* [win 0 ][win 1 ]
* [0][1][2][X][4][5][6][7][0][1][2][X][4][5][6][7]
*
* The for(sfb) steps through the sfb's 0-7 in win 0.
*
* Finding sfb[3]'s codebook == NOISE_HCB, the code
* steps through all the windows in the group (they share
* the same scalefactors) and replaces that sfb with noise.
*/
if (codebook < NOISE_HCB)
{
if (mask_enabled != FALSE)
{
band_length = band_stop - band_start;
ms_synt(
wins_in_group,
coef_per_win,
sfb_per_win,
band_length,
&(pCoefLeft[band_start]),
&(pCoefRight[band_start]),
&(q_formatLeft[tot_sfb]),
&(q_formatRight[tot_sfb]));
}
}
band_start = band_stop;
tot_sfb++;
} /* for (sfb) */
/*
* Increment pCoefRight and pCoefLeft by
* coef_per_win * the number of windows
*/
pCoefRight += coef_per_win * wins_in_group;
pCoefLeft += coef_per_win * wins_in_group--;
/*
* Increase tot_sfb by sfb_per_win times the number of windows minus 1.
* The minus 1 comes from the fact that tot_sfb is already pointing
* to the first sfb in the 2nd window of the group.
*/
tot_sfb += sfb_per_win * wins_in_group;
window_start = partition;
}
while (partition < pFrameInfo->num_win);
/* pFrameInfo->num_win = 1 for long windows, 8 for short_windows */
return;
} /* apply_ms_synt() */

View File

@@ -0,0 +1,94 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./include/apply_ms_synt.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
This file includes the function declaration for apply_ms_synt().
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef APPLY_MS_SYNT_H
#define APPLY_MS_SYNT_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "s_frameinfo.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
void apply_ms_synt(
const FrameInfo * const pFrameInfo,
const Int group[],
const Bool mask_map[],
const Int codebook_map[],
Int32 coefLeft[],
Int32 coefRight[],
Int q_formatLeft[MAXBANDS],
Int q_formatRight[MAXBANDS]);
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,424 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: apply_tns.c
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Inputs:
coef = Array of input coefficients.
[Int32 *, length 1024]
q_format = Array of q-formats, one per scalefactor band, for the
entire frame. In the case of tns_inv_filter, only the
first element is used, since the input to tns_inv_filter
is all of the same q-format.
[Int * const, length MAX_SFB]
pFrameInfo = Pointer to structure that holds information about each group.
(long block flag, number of windows, scalefactor bands
per group, etc.)
[const FrameInfo * const]
pTNS_frame_info = pointer to structure containing the details on each
TNS filter (order, filter coefficients,
coefficient res., etc.)
[TNS_frame_info * const]
inverse_flag = TRUE if inverse filter is to be applied.
FALSE if forward filter is to be applied.
[Bool]
scratch_Int_buffer = Pointer to scratch memory to store the
filter's state memory. Used by both
tns_inv_filter.
[Int *, length TNS_MAX_ORDER]
Local Stores/Buffers/Pointers Needed:
None
Global Stores/Buffers/Pointers Needed:
None
Outputs:
None
Pointers and Buffers Modified:
coef[] = TNS altered data.
q_format = q-formats in TNS scalefactor bands may be modified.
Local Stores Modified:
None
Global Stores Modified:
None
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
This function applies either the TNS forward or TNS inverse filter, based
on inverse_flag being FALSE or TRUE, respectively.
For the TNS forward filter, the data fed into tns_ar_filter is normalized
all to the same q-format.
------------------------------------------------------------------------------
REQUIREMENTS
The input, coef, should use all 32-bits, else the scaling by tns_ar_filter
may eliminate the data.
------------------------------------------------------------------------------
REFERENCES
(1) ISO/IEC 14496-3:1999(E)
Part 3
Subpart 4.6.8 (Temporal Noise Shaping)
------------------------------------------------------------------------------
PSEUDO-CODE
NO PSEUDO-CODE
------------------------------------------------------------------------------
RESOURCES USED
When the code is written for a specific target processor
the resources used should be documented below.
STACK USAGE: [stack count for this module] + [variable to represent
stack usage for each subroutine called]
where: [stack usage variable] = stack usage for [subroutine
name] (see [filename].ext)
DATA MEMORY USED: x words
PROGRAM MEMORY USED: x words
CLOCK CYCLES: [cycle count equation for this module] + [variable
used to represent cycle count for each subroutine
called]
where: [cycle count variable] = cycle count for [subroutine
name] (see [filename].ext)
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "s_tns_frame_info.h"
#include "s_tnsfilt.h"
#include "s_frameinfo.h"
#include "tns_inv_filter.h"
#include "tns_ar_filter.h"
#include "apply_tns.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
void apply_tns(
Int32 coef[],
Int q_format[],
const FrameInfo * const pFrameInfo,
TNS_frame_info * const pTNS_frame_info,
const Bool inverse_flag,
Int32 scratch_Int_buffer[])
{
Int num_tns_bands;
Int num_TNS_coef;
Int f;
Int tempInt;
Int tempInt2;
Int sfb_per_win;
Int sfbWidth;
Int coef_per_win;
Int min_q;
Int win;
Int32 *pCoef = coef;
Int32 *pTempCoef;
Int *pStartQformat = q_format;
Int *pQformat;
Int32 *pLpcCoef;
Int sfb_offset;
const Int16 *pWinSfbTop;
TNSfilt *pFilt;
coef_per_win = pFrameInfo->coef_per_win[0];
sfb_per_win = pFrameInfo->sfb_per_win[0];
win = 0;
pLpcCoef = pTNS_frame_info->lpc_coef;
pFilt = pTNS_frame_info->filt;
do
{
for (f = pTNS_frame_info->n_filt[win]; f > 0; f--)
{
/* Skip to the next filter if the order is 0 */
tempInt = pFilt->order;
if (tempInt > 0)
{
/*
* Do not call tns_ar_filter or tns_inv_filter
* if the difference
* between start_coef and stop_stop is <= 0.
*
*/
num_TNS_coef = (pFilt->stop_coef - pFilt->start_coef);
if (num_TNS_coef > 0)
{
if (inverse_flag != FALSE)
{
tns_inv_filter(
&(pCoef[pFilt->start_coef]),
num_TNS_coef,
pFilt->direction,
pLpcCoef,
pFilt->q_lpc,
pFilt->order,
scratch_Int_buffer);
}
else
{
num_tns_bands = (pFilt->stop_band - pFilt->start_band);
/*
* pQformat is initialized only once.
*
* Here is how TNS is applied on scalefactor bands
*
* [0][1][2][3][4][5][6][7][8]
* | \
* start_band stop_band
*
* In this example, TNS would be applied to 8
* scalefactor bands, 0-7.
*
* pQformat is initially set to &(pStartQformat[8])
*
* 1st LOOP
* Entry: pQformat = &(pStartQformat[8])
*
* pQformat is pre-decremented 8 times in the
* search for min_q
*
* Exit: pQformat = &(pStartQformat[0])
*
* 2nd LOOP
* Entry: pQformat = &(pStartQformat[0])
*
* pQformat is post-incremented 8 times in the
* normalization of the data loop.
*
* Exit: pQformat = &(pStartQformat[8]
*
*
* shift_amt = tns_ar_filter(...)
*
* 3rd LOOP
* Entry: pQformat = &(pStartQformat[8])
*
* pQformat is pre-decremented 8 times in the
* adjustment of the q-format to min_q - shift_amt
*
* Exit: pQformat = &(pStartQformat[0])
*
*/
pQformat =
&(pStartQformat[pFilt->stop_band]);
/*
* Scan the array of q-formats and find the minimum over
* the range where the filter is to be applied.
*
* At the end of this scan,
* pQformat = &(q-format[pFilt->start_band]);
*
*/
min_q = INT16_MAX;
for (tempInt = num_tns_bands; tempInt > 0; tempInt--)
{
tempInt2 = *(--pQformat);
if (tempInt2 < min_q)
{
min_q = tempInt2;
}
} /* for(tempInt = num_bands; tempInt > 0; tempInt--)*/
/*
* Set up the pointers so we can index into coef[]
* on a scalefactor band basis.
*/
tempInt = pFilt->start_band;
tempInt--;
/* Initialize sfb_offset and pWinSfbTop */
if (tempInt >= 0)
{
pWinSfbTop =
&(pFrameInfo->win_sfb_top[win][tempInt]);
sfb_offset = *(pWinSfbTop++);
}
else
{
pWinSfbTop = pFrameInfo->win_sfb_top[win];
sfb_offset = 0;
}
pTempCoef = pCoef + pFilt->start_coef;
/* Scale the data in the TNS bands to min_q q-format */
for (tempInt = num_tns_bands; tempInt > 0; tempInt--)
{
sfbWidth = *(pWinSfbTop++) - sfb_offset;
sfb_offset += sfbWidth;
tempInt2 = *(pQformat++) - min_q;
/*
* This should zero out the data in one scalefactor
* band if it is so much less than the neighboring
* scalefactor bands.
*
* The only way this "should" happen is if one
* scalefactor band contains zero data.
*
* Zero data can be of any q-format, but we always
* set it very high to avoid the zero-data band being
* picked as the one to normalize to in the scan for
* min_q.
*
*/
if (tempInt2 > 31)
{
tempInt2 = 31;
}
for (sfbWidth >>= 2; sfbWidth > 0; sfbWidth--)
{
*(pTempCoef++) >>= tempInt2;
*(pTempCoef++) >>= tempInt2;
*(pTempCoef++) >>= tempInt2;
*(pTempCoef++) >>= tempInt2;
}
} /* for(tempInt = num_bands; tempInt > 0; tempInt--)*/
tempInt2 =
tns_ar_filter(
&(pCoef[pFilt->start_coef]),
num_TNS_coef,
pFilt->direction,
pLpcCoef,
pFilt->q_lpc,
pFilt->order);
/*
* Update the q-format for all the scalefactor bands
* taking into account the adjustment caused by
* tns_ar_filter
*/
min_q -= tempInt2;
for (tempInt = num_tns_bands; tempInt > 0; tempInt--)
{
*(--pQformat) = min_q;
}
} /* if (inverse_flag != FALSE) */
} /* if (num_TNS_coef > 0) */
pLpcCoef += pFilt->order;
} /* if (tempInt > 0) */
pFilt++;
} /* for (f = pTNSinfo->n_filt; f > 0; f--) */
pCoef += coef_per_win;
pStartQformat += sfb_per_win;
win++;
}
while (win < pFrameInfo->num_win);
return;
} /* apply_tns() */

View File

@@ -0,0 +1,113 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./include/apply_tns.h
------------------------------------------------------------------------------
REVISION HISTORY
Description: Updated per review comments.
Description: Changed function prototype to mirror changes made in apply_tns.c
Description: The scratch memory was mistakenly declared here as type "Int32"
It should have been "Int"
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
This include file contains the function declaration for
apply_tns.c
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef APPLY_TNS_H
#define APPLY_TNS_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "s_tns_frame_info.h"
#include "s_frameinfo.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
{
#endif
void apply_tns(
Int32 coef[],
Int q_format[],
const FrameInfo * const pFrameInfo,
TNS_frame_info * const pTNS_frame_info,
const Bool inverse_flag,
Int32 scratch_Int_buffer[]);
#ifdef __cplusplus
}
#endif
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,93 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./include/bit_reversal_swap.h
------------------------------------------------------------------------------
REVISION HISTORY
Description: Changed definitions from Int to Int32 for Data[]
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
Header file for function bit_reversal_swap()
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef BIT_REVERSAL_SWAP_H
#define BIT_REVERSAL_SWAP_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
extern const Int Index_64_a[];
extern const Int Index_64_b[];
extern const Int Index_512_a[];
extern const Int Index_512_b[];
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
void bit_reversal_swap(
Int32 Data[],
const Int *pIndex_a,
const Int *pIndex_b);
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif /* BIT_REVERSAL_SWAP_H */

View File

@@ -0,0 +1,167 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: buf_getbits.c
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Arguments: hBitBuf Handle to Bitbuffer
n Number of bits to read
Return: bits
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
Reads n bits from Bitbuffer
------------------------------------------------------------------------------
REQUIREMENTS
------------------------------------------------------------------------------
REFERENCES
SC 29 Software Copyright Licencing Disclaimer:
This software module was originally developed by
Coding Technologies
and edited by
-
in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
standards for reference purposes and its performance may not have been
optimized. This software module is an implementation of one or more tools as
specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
ISO/IEC gives users free license to this software module or modifications
thereof for use in products claiming conformance to audiovisual and
image-coding related ITU Recommendations and/or ISO/IEC International
Standards. ISO/IEC gives users the same free license to this software module or
modifications thereof for research purposes and further ISO/IEC standardisation.
Those intending to use this software module in products are advised that its
use may infringe existing patents. ISO/IEC have no liability for use of this
software module or modifications thereof. Copyright is not released for
products that do not conform to audiovisual and image-coding related ITU
Recommendations and/or ISO/IEC International Standards.
The original developer retains full right to modify and use the code for its
own purpose, assign or donate the code to a third party and to inhibit third
parties from using the code for products that do not conform to audiovisual and
image-coding related ITU Recommendations and/or ISO/IEC International Standards.
This copyright notice must be included in all copies or derivative works.
Copyright (c) ISO/IEC 2002.
------------------------------------------------------------------------------
PSEUDO-CODE
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#ifdef AAC_PLUS
#include "buf_getbits.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
UInt32 buf_getbits(BIT_BUFFER * hBitBuf, Int32 n)
{
/* read bits from MSB side */
if (hBitBuf->buffered_bits <= 16)
{
hBitBuf->buffer_word = (hBitBuf->buffer_word << 16) | (*(hBitBuf->char_ptr++) << 8);
hBitBuf->buffer_word |= *(hBitBuf->char_ptr++);
hBitBuf->buffered_bits += 16;
}
hBitBuf->buffered_bits -= n;
hBitBuf->nrBitsRead += n;
return ((hBitBuf->buffer_word >> hBitBuf->buffered_bits) & ((1 << n) - 1));
}
UInt32 buf_get_1bit(BIT_BUFFER * hBitBuf)
{
/* read bits from MSB side */
if (hBitBuf->buffered_bits <= 16)
{
hBitBuf->buffer_word = (hBitBuf->buffer_word << 16) | (*(hBitBuf->char_ptr++) << 8);
hBitBuf->buffer_word |= *(hBitBuf->char_ptr++);
hBitBuf->buffered_bits += 16;
}
hBitBuf->buffered_bits--;
hBitBuf->nrBitsRead++;
return ((hBitBuf->buffer_word >> hBitBuf->buffered_bits) & 1);
}
#endif

View File

@@ -0,0 +1,94 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: buf_getbits.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef BUF_GETBITS_H
#define BUF_GETBITS_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "s_bit_buffer.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
{
#endif
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
UInt32 buf_getbits(BIT_BUFFER * hBitBuf, Int32 n);
UInt32 buf_get_1bit(BIT_BUFFER * hBitBuf);
#ifdef __cplusplus
}
#endif
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,93 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./include/buffer_normalization.h
------------------------------------------------------------------------------
REVISION HISTORY
Description: Changed definitions from Int to Int32 for IO_buffer[]
Description: Added copyrigth notice, added 'const' definitions to function
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
Header file for function buffer_normalization()
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef BUFFER_NORMALIZATION_H
#define BUFFER_NORMALIZATION_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
#define ALL_ZEROS_BUFFER -100
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
void buffer_normalization(
Int q_format,
Int32 IO_buffer[],
const Int buffer_size,
Int * const pExp);
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif /* BUFFER_NORMALIZATION_H */

View File

@@ -0,0 +1,179 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Inputs:
pInputStream = pointer to a BITS structure that holds information
regarding the input stream.
Local Stores/Buffers/Pointers Needed:
None
Global Stores/Buffers/Pointers Needed:
None
Outputs:
None
Pointers and Buffers Modified:
pInputStream->usedBits is rounded up to a number that represents the next
byte boundary.
Local Stores Modified:
None
Global Stores Modified:
None
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
Makes the input stream structure pointed to align to the next byte boundary.
If it is already at a byte boundary it is left alone.
------------------------------------------------------------------------------
REQUIREMENTS
This function shall not use global or static variables.
------------------------------------------------------------------------------
REFERENCES
(1) MPEG-2 NBC Audio Decoder
"This software module was originally developed by AT&T, Dolby
Laboratories, Fraunhofer Gesellschaft IIS in the course of development
of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
3. This software module is an implementation of a part of one or more
MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
standards free license to this software module or modifications thereof
for use in hardware or software products claiming conformance to the
MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
module in hardware or software products are advised that this use may
infringe existing patents. The original developer of this software
module and his/her company, the subsequent editors and their companies,
and ISO/IEC have no liability for use of this software module or
modifications thereof in an implementation. Copyright is not released
for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
developer retains full right to use the code for his/her own purpose,
assign or donate the code to a third party and to inhibit third party
from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
This copyright notice must be included in all copies or derivative
works."
Copyright(c)1996.
------------------------------------------------------------------------------
PSEUDO-CODE
void byte_align(
BITS *pInputStream)
MODIFYING(pInputStream->usedBits = pInputStream->usedBits +
(pInputStream->usedBits + 7) % 8)
RETURN(nothing)
------------------------------------------------------------------------------
RESOURCES USED
STACK USAGE:
where:
DATA MEMORY USED: x words
PROGRAM MEMORY USED: x words
CLOCK CYCLES:
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "s_bits.h"
#include "ibstream.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*
* A negative number was used for this mask so that it works on both
* 16-bit or 32-bit machines. The mask must be cast to unsigned int to
* work with TI compiler, ver 1.80.
*/
#define BYTE_ALIGN_MASK ((UInt)(-8))
#define BYTE_ALIGN_ROUNDUP 7
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL VARIABLE DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
void byte_align(
BITS *pInputStream)
{
/*
* Round up to the next byte by adding 7 and masking off with
* FFF8 or FFFFFFF8. The masking operation is a faster way to
* perform modulo arithmetic if the number is a power of 2.
*
* This code is the same as
* pInputStream->usedBits += (pInputStream->usedBits + 7) % 8
*/
pInputStream->usedBits += BYTE_ALIGN_ROUNDUP;
pInputStream->usedBits &= BYTE_ALIGN_MASK;
return;
}

View File

@@ -0,0 +1,416 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: calc_auto_corr.c
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
------------------------------------------------------------------------------
REQUIREMENTS
------------------------------------------------------------------------------
REFERENCES
SC 29 Software Copyright Licencing Disclaimer:
This software module was originally developed by
Coding Technologies
and edited by
-
in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
standards for reference purposes and its performance may not have been
optimized. This software module is an implementation of one or more tools as
specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
ISO/IEC gives users free license to this software module or modifications
thereof for use in products claiming conformance to audiovisual and
image-coding related ITU Recommendations and/or ISO/IEC International
Standards. ISO/IEC gives users the same free license to this software module or
modifications thereof for research purposes and further ISO/IEC standardisation.
Those intending to use this software module in products are advised that its
use may infringe existing patents. ISO/IEC have no liability for use of this
software module or modifications thereof. Copyright is not released for
products that do not conform to audiovisual and image-coding related ITU
Recommendations and/or ISO/IEC International Standards.
The original developer retains full right to modify and use the code for its
own purpose, assign or donate the code to a third party and to inhibit third
parties from using the code for products that do not conform to audiovisual and
image-coding related ITU Recommendations and/or ISO/IEC International Standards.
This copyright notice must be included in all copies or derivative works.
Copyright (c) ISO/IEC 2002.
------------------------------------------------------------------------------
PSEUDO-CODE
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#ifdef AAC_PLUS
#include "calc_auto_corr.h"
#include "aac_mem_funcs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
#include "fxp_mul32.h"
#include "pv_normalize.h"
#define N 2
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
void calc_auto_corr_LC(struct ACORR_COEFS *ac,
Int32 realBuf[][32],
Int32 bd,
Int32 len)
{
Int32 j;
Int32 temp1;
Int32 temp3;
Int32 temp5;
int64_t temp_r01r;
int64_t temp_r02r;
int64_t temp_r11r;
int64_t temp_r12r;
int64_t temp_r22r;
int64_t max = 0;
temp1 = (realBuf[ 0][bd]) >> N;
temp3 = (realBuf[-1][bd]) >> N;
temp5 = (realBuf[-2][bd]) >> N;
temp_r11r = fxp_mac64_Q31(0, temp3, temp3); /* [j-1]*[j-1] */
temp_r12r = fxp_mac64_Q31(0, temp3, temp5); /* [j-1]*[j-2] */
temp_r22r = fxp_mac64_Q31(0, temp5, temp5); /* [j-2]*[j-2] */
temp_r01r = 0;
temp_r02r = 0;
for (j = 1; j < len; j++)
{
temp_r01r = fxp_mac64_Q31(temp_r01r, temp1, temp3); /* [j ]*[j-1] */
temp_r02r = fxp_mac64_Q31(temp_r02r, temp1, temp5); /* [j ]*[j-2] */
temp_r11r = fxp_mac64_Q31(temp_r11r, temp1, temp1); /* [j-1]*[j-1] */
temp5 = temp3;
temp3 = temp1;
temp1 = (realBuf[j][bd]) >> N;
}
temp_r22r += temp_r11r;
temp_r12r += temp_r01r; /* [j-1]*[j-2] */
temp_r22r = fxp_mac64_Q31(temp_r22r, -temp3, temp3);
temp_r01r = fxp_mac64_Q31(temp_r01r, temp1, temp3);
temp_r02r = fxp_mac64_Q31(temp_r02r, temp1, temp5);
max |= temp_r01r ^(temp_r01r >> 63);
max |= temp_r02r ^(temp_r02r >> 63);
max |= temp_r11r;
max |= temp_r12r ^(temp_r12r >> 63);
max |= temp_r22r;
if (max)
{
temp1 = (UInt32)(max >> 32);
if (temp1)
{
temp3 = 33 - pv_normalize(temp1);
ac->r01r = (Int32)(temp_r01r >> temp3);
ac->r02r = (Int32)(temp_r02r >> temp3);
ac->r11r = (Int32)(temp_r11r >> temp3);
ac->r12r = (Int32)(temp_r12r >> temp3);
ac->r22r = (Int32)(temp_r22r >> temp3);
}
else
{
temp3 = pv_normalize(((UInt32)max) >> 1) - 2;
if (temp3 > 0)
{
ac->r01r = (Int32)(temp_r01r << temp3);
ac->r02r = (Int32)(temp_r02r << temp3);
ac->r11r = (Int32)(temp_r11r << temp3);
ac->r12r = (Int32)(temp_r12r << temp3);
ac->r22r = (Int32)(temp_r22r << temp3);
}
else
{
temp3 = -temp3;
ac->r01r = (Int32)(temp_r01r >> temp3);
ac->r02r = (Int32)(temp_r02r >> temp3);
ac->r11r = (Int32)(temp_r11r >> temp3);
ac->r12r = (Int32)(temp_r12r >> temp3);
ac->r22r = (Int32)(temp_r22r >> temp3);
}
}
/*
* ac->det = ac->r11r*ac->r22r - rel*(ac->r12r*ac->r12r);
*/
/* 1/(1 + 1e-6) == 1 - 1e-6 */
/* 2^-20 == 1e-6 */
ac->det = fxp_mul32_Q30(ac->r12r, ac->r12r);
ac->det -= ac->det >> 20;
ac->det = fxp_mul32_Q30(ac->r11r, ac->r22r) - ac->det;
}
else
{
pv_memset((void *)ac, 0, sizeof(struct ACORR_COEFS));
}
}
#ifdef HQ_SBR
void calc_auto_corr(struct ACORR_COEFS *ac,
Int32 realBuf[][32],
Int32 imagBuf[][32],
Int32 bd,
Int32 len)
{
Int32 j;
Int32 temp1;
Int32 temp2;
Int32 temp3;
Int32 temp4;
Int32 temp5;
Int32 temp6;
int64_t accu1 = 0;
int64_t accu2 = 0;
int64_t accu3 = 0;
int64_t accu4 = 0;
int64_t accu5 = 0;
int64_t temp_r12r;
int64_t temp_r12i;
int64_t temp_r22r;
int64_t max = 0;
temp1 = realBuf[0 ][bd] >> N;
temp2 = imagBuf[0 ][bd] >> N;
temp3 = realBuf[0-1][bd] >> N;
temp4 = imagBuf[0-1][bd] >> N;
temp5 = realBuf[0-2][bd] >> N;
temp6 = imagBuf[0-2][bd] >> N;
temp_r22r = fxp_mac64_Q31(0, temp5, temp5);
temp_r22r = fxp_mac64_Q31(temp_r22r, temp6, temp6);
temp_r12r = fxp_mac64_Q31(0, temp3, temp5);
temp_r12r = fxp_mac64_Q31(temp_r12r, temp4, temp6);
temp_r12i = -fxp_mac64_Q31(0, temp3, temp6);
temp_r12i = fxp_mac64_Q31(temp_r12i, temp4, temp5);
for (j = 1; j < len; j++)
{
accu1 = fxp_mac64_Q31(accu1, temp3, temp3);
accu1 = fxp_mac64_Q31(accu1, temp4, temp4);
accu2 = fxp_mac64_Q31(accu2, temp1, temp3);
accu2 = fxp_mac64_Q31(accu2, temp2, temp4);
accu3 = fxp_mac64_Q31(accu3, temp2, temp3);
accu3 = fxp_mac64_Q31(accu3, -temp1, temp4);
accu4 = fxp_mac64_Q31(accu4, temp1, temp5);
accu4 = fxp_mac64_Q31(accu4, temp2, temp6);
accu5 = fxp_mac64_Q31(accu5, temp2, temp5);
accu5 = fxp_mac64_Q31(accu5, -temp1, temp6);
temp5 = temp3;
temp6 = temp4;
temp3 = temp1;
temp4 = temp2;
temp1 = realBuf[j][bd] >> N;
temp2 = imagBuf[j][bd] >> N;
}
temp_r22r += accu1;
temp_r12r += accu2;
temp_r12i += accu3;
accu1 = fxp_mac64_Q31(accu1, temp3, temp3);
accu1 = fxp_mac64_Q31(accu1, temp4, temp4);
accu2 = fxp_mac64_Q31(accu2, temp1, temp3);
accu2 = fxp_mac64_Q31(accu2, temp2, temp4);
accu3 = fxp_mac64_Q31(accu3, temp2, temp3);
accu3 = fxp_mac64_Q31(accu3, -temp1, temp4);
accu4 = fxp_mac64_Q31(accu4, temp1, temp5);
accu4 = fxp_mac64_Q31(accu4, temp2, temp6);
accu5 = fxp_mac64_Q31(accu5, temp2, temp5);
accu5 = fxp_mac64_Q31(accu5, -temp1, temp6);
max |= accu5 ^(accu5 >> 63);
max |= accu4 ^(accu4 >> 63);
max |= accu3 ^(accu3 >> 63);
max |= accu2 ^(accu2 >> 63);
max |= accu1;
max |= temp_r12r ^(temp_r12r >> 63);
max |= temp_r12i ^(temp_r12i >> 63);
max |= temp_r22r;
if (max)
{
temp1 = (UInt32)(max >> 32);
if (temp1)
{
temp1 = 34 - pv_normalize(temp1);
ac->r11r = (Int32)(accu1 >> temp1);
ac->r01r = (Int32)(accu2 >> temp1);
ac->r01i = (Int32)(accu3 >> temp1);
ac->r02r = (Int32)(accu4 >> temp1);
ac->r02i = (Int32)(accu5 >> temp1);
ac->r12r = (Int32)(temp_r12r >> temp1);
ac->r12i = (Int32)(temp_r12i >> temp1);
ac->r22r = (Int32)(temp_r22r >> temp1);
}
else
{
temp1 = pv_normalize(((UInt32)max) >> 1) - 3;
if (temp1 > 0)
{
ac->r11r = (Int32)(accu1 << temp1);
ac->r01r = (Int32)(accu2 << temp1);
ac->r01i = (Int32)(accu3 << temp1);
ac->r02r = (Int32)(accu4 << temp1);
ac->r02i = (Int32)(accu5 << temp1);
ac->r12r = (Int32)(temp_r12r << temp1);
ac->r12i = (Int32)(temp_r12i << temp1);
ac->r22r = (Int32)(temp_r22r << temp1);
}
else
{
temp1 = -temp1;
ac->r11r = (Int32)(accu1 >> temp1);
ac->r01r = (Int32)(accu2 >> temp1);
ac->r01i = (Int32)(accu3 >> temp1);
ac->r02r = (Int32)(accu4 >> temp1);
ac->r02i = (Int32)(accu5 >> temp1);
ac->r12r = (Int32)(temp_r12r >> temp1);
ac->r12i = (Int32)(temp_r12i >> temp1);
ac->r22r = (Int32)(temp_r22r >> temp1);
}
}
/*
* ac->det = ac->r11r*ac->r22r - rel*(ac->r12r*ac->r12r);
*/
/* 1/(1 + 1e-6) == 1 - 1e-6 */
/* 2^-20 == 1e-6 */
ac->det = fxp_mul32_Q29(ac->r12i, ac->r12i);
ac->det = fxp_mac32_Q29(ac->r12r, ac->r12r, ac->det);
ac->det -= ac->det >> 20;
ac->det = -fxp_msu32_Q29(ac->r11r, ac->r22r, ac->det);
}
else
{
pv_memset((void *)ac, 0, sizeof(struct ACORR_COEFS));
}
}
#endif
#endif

View File

@@ -0,0 +1,122 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: calc_auto_corr.h
Funtions:
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef CALC_AUTO_CORR_H
#define CALC_AUTO_CORR_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
struct ACORR_COEFS
{
Int32 r11r;
Int32 r01r;
Int32 r02r;
Int32 r12r;
Int32 r22r;
#ifdef HQ_SBR
Int32 r01i;
Int32 r02i;
Int32 r12i;
#endif
Int32 det;
};
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
{
#endif
void calc_auto_corr_LC(struct ACORR_COEFS *ac,
Int32 realBuf[][32],
Int32 bd,
Int32 len);
#ifdef HQ_SBR
void calc_auto_corr(struct ACORR_COEFS *ac,
Int32 realBuf[][32],
Int32 imagBuf[][32],
Int32 bd,
Int32 len);
#endif
#ifdef __cplusplus
}
#endif
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,267 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./src/calc_gsfb_table.c
------------------------------------------------------------------------------
REVISION HISTORY
Description: Modified from original shareware code
Description: (1) Modified to bring in-line with PV standards
(2) Removed if(pFrameInfo->islong), only short windows will
call this routine from getics.c
Description: Modified per review comments
Who: Date:
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Inputs:
pFrameInfo = pointer to structure that holds information for current
frame. Data type FrameInfo
group[] = array that contains the grouping information of short
windows (stop index of windows in each group).
Data type Int
Local Stores/Buffers/Pointers Needed:
None
Global Stores/Buffers/Pointers Needed:
None
Outputs:
None
Pointers and Buffers Modified:
pFrameInfo -> frame_sfb_top contains the cumulative bandwidth of
scalefactor bands in each group
Local Stores Modified:
None
Global Stores Modified:
None
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
This function is only invoked when short windows are present. It calculates
the number of groups in one frame, and the scalefactor bandwidth of each
scalefactor band in each group.
All windows within one group share the same scalefactors and are interleaved
on a scalefactor band basis. Within each group, the actual length of one
scalefactor band equals to the number of windows times the number of
coefficients in a regular scalefactor band.
------------------------------------------------------------------------------
REQUIREMENTS
This function shall replace the contents of pFrameInfo->frame_sfb_top
with the cumulative bandwidth of each scalefactor band in each group
------------------------------------------------------------------------------
REFERENCES
(1) MPEG-2 NBC Audio Decoder
"This software module was originally developed by AT&T, Dolby
Laboratories, Fraunhofer Gesellschaft IIS in the course of development
of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
3. This software module is an implementation of a part of one or more
MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
standards free license to this software module or modifications thereof
for use in hardware or software products claiming conformance to the
MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
module in hardware or software products are advised that this use may
infringe existing patents. The original developer of this software
module and his/her company, the subsequent editors and their companies,
and ISO/IEC have no liability for use of this software module or
modifications thereof in an implementation. Copyright is not released
for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
developer retains full right to use the code for his/her own purpose,
assign or donate the code to a third party and to inhibit third party
from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
This copyright notice must be included in all copies or derivative
works."
Copyright(c)1996.
(2) ISO/IEC 14496-3: 1999(E)
Subpart 4 p54. 4.5.2.3.2 decoding process
------------------------------------------------------------------------------
PSEUDO-CODE
offset = 0;
group_idx = 0;
DO
pFrameInfo->group_len[group_idx] = group[group_idx] - offset;
offset = group[group_idx];
group_idx++;
WHILE (offset < NUM_SHORT_WINDOWS);
pFrameInfo->num_groups = group_idx;
pFrameSfbTop = pFrameInfo->frame_sfb_top;
offset = 0;
FOR (group_idx = 0; group_idx < pFrameInfo->num_groups; group_idx++)
len = pFrameInfo->group_len[group_idx];
FOR (sfb = 0; sfb < pFrameInfo->sfb_per_win[group_idx]; sfb++)
offset += pFrameInfo->sfb_width_128[sfb] * len;
*pFrameSfbTop++ = offset;
ENDFOR
ENDFOR
------------------------------------------------------------------------------
RESOURCES USED
When the code is written for a specific target processor the
the resources used should be documented below.
STACK USAGE: [stack count for this module] + [variable to represent
stack usage for each subroutine called]
where: [stack usage variable] = stack usage for [subroutine
name] (see [filename].ext)
DATA MEMORY USED: x words
PROGRAM MEMORY USED: x words
CLOCK CYCLES: [cycle count equation for this module] + [variable
used to represent cycle count for each subroutine
called]
where: [cycle count variable] = cycle count for [subroutine
name] (see [filename].ext)
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "huffman.h"
#include "aac_mem_funcs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
void calc_gsfb_table(
FrameInfo *pFrameInfo,
Int group[])
{
Int group_idx;
Int offset;
Int *pFrameSfbTop;
Int *pSfbWidth128;
Int sfb;
Int nsfb;
Int len;
Int ngroups;
/* clear out the default values set by infoinit */
/* */
pv_memset(pFrameInfo->frame_sfb_top,
0,
MAXBANDS*sizeof(pFrameInfo->frame_sfb_top[0]));
/* */
/* first calculate the group length*/
offset = 0;
ngroups = 0;
do
{
pFrameInfo->group_len[ngroups] = group[ngroups] - offset;
offset = group[ngroups];
ngroups++;
}
while (offset < NUM_SHORT_WINDOWS);
/* calculate the cumulative scalefactor bandwidth for one frame */
pFrameInfo->num_groups = ngroups;
pFrameSfbTop = pFrameInfo->frame_sfb_top;
offset = 0;
for (group_idx = 0; group_idx < ngroups; group_idx++)
{
len = pFrameInfo->group_len[ group_idx];
nsfb = pFrameInfo->sfb_per_win[group_idx];
pSfbWidth128 = pFrameInfo->sfb_width_128;
for (sfb = nsfb; sfb > 0; sfb--)
{
offset += *pSfbWidth128++ * len;
*pFrameSfbTop++ = offset;
}
}
} /* calc_gsfb_table */

View File

@@ -0,0 +1,360 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: calc_sbr_anafilterbank.c
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
------------------------------------------------------------------------------
REQUIREMENTS
------------------------------------------------------------------------------
REFERENCES
SC 29 Software Copyright Licencing Disclaimer:
This software module was originally developed by
Coding Technologies
and edited by
-
in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
standards for reference purposes and its performance may not have been
optimized. This software module is an implementation of one or more tools as
specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
ISO/IEC gives users free license to this software module or modifications
thereof for use in products claiming conformance to audiovisual and
image-coding related ITU Recommendations and/or ISO/IEC International
Standards. ISO/IEC gives users the same free license to this software module or
modifications thereof for research purposes and further ISO/IEC standardisation.
Those intending to use this software module in products are advised that its
use may infringe existing patents. ISO/IEC have no liability for use of this
software module or modifications thereof. Copyright is not released for
products that do not conform to audiovisual and image-coding related ITU
Recommendations and/or ISO/IEC International Standards.
The original developer retains full right to modify and use the code for its
own purpose, assign or donate the code to a third party and to inhibit third
parties from using the code for products that do not conform to audiovisual and
image-coding related ITU Recommendations and/or ISO/IEC International Standards.
This copyright notice must be included in all copies or derivative works.
Copyright (c) ISO/IEC 2002.
------------------------------------------------------------------------------
PSEUDO-CODE
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#ifdef AAC_PLUS
#include "calc_sbr_anafilterbank.h"
#include "qmf_filterbank_coeff.h"
#include "analysis_sub_band.h"
#include "aac_mem_funcs.h"
#include "fxp_mul32.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
void calc_sbr_anafilterbank_LC(Int32 * Sr,
Int16 * X,
Int32 scratch_mem[][64],
Int32 maxBand)
{
Int i;
Int32 *p_Y_1;
Int32 *p_Y_2;
Int16 * pt_X_1;
Int16 * pt_X_2;
Int32 realAccu1;
Int32 realAccu2;
Int32 tmp1;
Int32 tmp2;
const Int32 * pt_C;
p_Y_1 = scratch_mem[0];
p_Y_2 = p_Y_1 + 63;
pt_C = &sbrDecoderFilterbankCoefficients_an_filt_LC[0];
pt_X_1 = X;
realAccu1 = fxp_mul32_by_16(Qfmt27(-0.51075594183097F), pt_X_1[-192]);
realAccu1 = fxp_mac32_by_16(Qfmt27(-0.51075594183097F), -pt_X_1[-128], realAccu1);
realAccu1 = fxp_mac32_by_16(Qfmt27(-0.01876919066980F), pt_X_1[-256], realAccu1);
*(p_Y_1++) = fxp_mac32_by_16(Qfmt27(-0.01876919066980F), -pt_X_1[ -64], realAccu1);
/* create array Y */
pt_X_1 = &X[-1];
pt_X_2 = &X[-319];
for (i = 15; i != 0; i--)
{
tmp1 = *(pt_X_1--);
tmp2 = *(pt_X_2++);
realAccu1 = fxp_mul32_by_16(*(pt_C), tmp1);
realAccu2 = fxp_mul32_by_16(*(pt_C++), tmp2);
tmp1 = pt_X_1[ -63];
tmp2 = pt_X_2[ +63];
realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
tmp1 = pt_X_1[ -127];
tmp2 = pt_X_2[ +127];
realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
tmp1 = pt_X_1[ -191];
tmp2 = pt_X_2[ +191];
realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
tmp1 = pt_X_1[ -255];
tmp2 = pt_X_2[ +255];
*(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
*(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
tmp1 = *(pt_X_1--);
tmp2 = *(pt_X_2++);
realAccu1 = fxp_mul32_by_16(*(pt_C), tmp1);
realAccu2 = fxp_mul32_by_16(*(pt_C++), tmp2);
tmp1 = pt_X_1[ -63];
tmp2 = pt_X_2[ +63];
realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
tmp1 = pt_X_1[ -127];
tmp2 = pt_X_2[ +127];
realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
tmp1 = pt_X_1[ -191];
tmp2 = pt_X_2[ +191];
realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
tmp1 = pt_X_1[ -255];
tmp2 = pt_X_2[ +255];
*(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
*(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
}
tmp1 = *(pt_X_1--);
tmp2 = *(pt_X_2++);
realAccu1 = fxp_mul32_by_16(*(pt_C), tmp1);
realAccu2 = fxp_mul32_by_16(*(pt_C++), tmp2);
tmp1 = pt_X_1[ -63];
tmp2 = pt_X_2[ +63];
realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
tmp1 = pt_X_1[ -127];
tmp2 = pt_X_2[ +127];
realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
tmp1 = pt_X_1[ -191];
tmp2 = pt_X_2[ +191];
realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
tmp1 = pt_X_1[ -255];
tmp2 = pt_X_2[ +255];
*(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
*(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
pt_X_1 = X;
realAccu2 = fxp_mul32_by_16(Qfmt27(0.00370548843500F), X[ -32]);
realAccu2 = fxp_mac32_by_16(Qfmt27(0.00370548843500F), pt_X_1[-288], realAccu2);
realAccu2 = fxp_mac32_by_16(Qfmt27(0.09949460091720F), pt_X_1[ -96], realAccu2);
realAccu2 = fxp_mac32_by_16(Qfmt27(0.09949460091720F), pt_X_1[-224], realAccu2);
*(p_Y_1++) = fxp_mac32_by_16(Qfmt27(1.20736865027288F), pt_X_1[-160], realAccu2);
analysis_sub_band_LC(scratch_mem[0],
Sr,
maxBand,
(Int32(*)[64])scratch_mem[1]);
}
#ifdef HQ_SBR
void calc_sbr_anafilterbank(Int32 * Sr,
Int32 * Si,
Int16 * X,
Int32 scratch_mem[][64],
Int32 maxBand)
{
Int i;
Int32 *p_Y_1;
Int32 *p_Y_2;
const Int32 * pt_C;
Int16 * pt_X_1;
Int16 * pt_X_2;
Int32 realAccu1;
Int32 realAccu2;
Int32 tmp1;
Int32 tmp2;
p_Y_1 = scratch_mem[0];
p_Y_2 = p_Y_1 + 63;
pt_C = &sbrDecoderFilterbankCoefficients_an_filt[0];
realAccu1 = fxp_mul32_by_16(Qfmt27(-0.36115899F), X[-192]);
realAccu1 = fxp_mac32_by_16(Qfmt27(-0.36115899F), -X[-128], realAccu1);
realAccu1 = fxp_mac32_by_16(Qfmt27(-0.013271822F), X[-256], realAccu1);
*(p_Y_1++) = fxp_mac32_by_16(Qfmt27(-0.013271822F), -X[ -64], realAccu1);
/* create array Y */
pt_X_1 = &X[-1];
pt_X_2 = &X[-319];
for (i = 31; i != 0; i--)
{
tmp1 = *(pt_X_1--);
tmp2 = *(pt_X_2++);
realAccu1 = fxp_mul32_by_16(*(pt_C), tmp1);
realAccu2 = fxp_mul32_by_16(*(pt_C++), tmp2);
tmp1 = pt_X_1[ -63];
tmp2 = pt_X_2[ 63];
realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
tmp1 = pt_X_1[ -127];
tmp2 = pt_X_2[ 127];
realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
tmp1 = pt_X_1[ -191];
tmp2 = pt_X_2[ 191];
realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
tmp1 = pt_X_1[ -255];
tmp2 = pt_X_2[ 255];
*(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
*(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
}
realAccu2 = fxp_mul32_by_16(Qfmt27(0.002620176F), X[ -32]);
realAccu2 = fxp_mac32_by_16(Qfmt27(0.002620176F), X[-288], realAccu2);
realAccu2 = fxp_mac32_by_16(Qfmt27(0.070353307F), X[ -96], realAccu2);
realAccu2 = fxp_mac32_by_16(Qfmt27(0.070353307F), X[-224], realAccu2);
*(p_Y_1++) = fxp_mac32_by_16(Qfmt27(0.85373856F), (X[-160]), realAccu2);
analysis_sub_band(scratch_mem[0],
Sr,
Si,
maxBand,
(Int32(*)[64])scratch_mem[1]);
}
#endif
#endif /* AAC_PLUS */

View File

@@ -0,0 +1,113 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: calc_sbr_anafilterbank.h
Funtions:
get_dse
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef CALC_SBR_ANAFILTERBANK_H
#define CALC_SBR_ANAFILTERBANK_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#ifdef __cplusplus
extern "C"
{
#endif
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
#define ROUND_ANAFIL 0
//#define ROUND_ANAFIL 0
#define ROUND_ANAFIL_LC (0)
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
void calc_sbr_anafilterbank_LC(Int32 * Sr,
Int16 * X,
Int32 scratch_mem[][64],
Int32 maxBand);
#ifdef HQ_SBR
void calc_sbr_anafilterbank(Int32 * Sr,
Int32 * Si,
Int16 * X,
Int32 scratch_mem[][64],
Int32 maxBand);
#endif
#ifdef __cplusplus
}
#endif
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif /* CALC_SBR_ANAFILTERBANK_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,144 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: calc_sbr_envelope.h
Funtions:
get_dse
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
SC 29 Software Copyright Licencing Disclaimer:
This software module was originally developed by
Coding Technologies
and edited by
-
in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
standards for reference purposes and its performance may not have been
optimized. This software module is an implementation of one or more tools as
specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
ISO/IEC gives users free license to this software module or modifications
thereof for use in products claiming conformance to audiovisual and
image-coding related ITU Recommendations and/or ISO/IEC International
Standards. ISO/IEC gives users the same free license to this software module or
modifications thereof for research purposes and further ISO/IEC standardisation.
Those intending to use this software module in products are advised that its
use may infringe existing patents. ISO/IEC have no liability for use of this
software module or modifications thereof. Copyright is not released for
products that do not conform to audiovisual and image-coding related ITU
Recommendations and/or ISO/IEC International Standards.
The original developer retains full right to modify and use the code for its
own purpose, assign or donate the code to a third party and to inhibit third
parties from using the code for products that do not conform to audiovisual and
image-coding related ITU Recommendations and/or ISO/IEC International Standards.
This copyright notice must be included in all copies or derivative works.
Copyright (c) ISO/IEC 2002.
$Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef CALCULATE_SBR_ENVELOPE_H
#define CALCULATE_SBR_ENVELOPE_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "s_sbr_frame_data.h"
#include "sbr_generate_high_freq.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
{
#endif
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
void calc_sbr_envelope(SBR_FRAME_DATA *frameData,
Int32 *aBufR,
Int32 *aBufI,
Int freqBandTable1[2][MAX_FREQ_COEFFS + 1],
const Int32 *nSfb,
Int32 freqBandTable2[MAX_NOISE_COEFFS + 1],
Int32 nNBands,
Int32 reset,
Int32 *degreeAlias,
Int32 *harm_index,
Int32 *phase_index,
Int32 hFp[64],
Int32 *sUp,
Int32 limSbc[][13],
Int32 *gateMode,
#ifdef HQ_SBR
Int32 *fBuf_man[64],
Int32 *fBuf_exp[64],
Int32 *fBufN_man[64],
Int32 *fBufN_exp[64],
#endif
Int32 scratch_mem[][64],
struct PATCH Patch,
Int32 sqrt_cache[][4],
Int32 LC_flag);
#ifdef __cplusplus
}
#endif
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif /* CALCULATE_SBR_ENVELOPE_H */

View File

@@ -0,0 +1,639 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: calc_sbr_synfilterbank.c
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
------------------------------------------------------------------------------
REQUIREMENTS
------------------------------------------------------------------------------
REFERENCES
SC 29 Software Copyright Licencing Disclaimer:
This software module was originally developed by
Coding Technologies
and edited by
-
in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
standards for reference purposes and its performance may not have been
optimized. This software module is an implementation of one or more tools as
specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
ISO/IEC gives users free license to this software module or modifications
thereof for use in products claiming conformance to audiovisual and
image-coding related ITU Recommendations and/or ISO/IEC International
Standards. ISO/IEC gives users the same free license to this software module or
modifications thereof for research purposes and further ISO/IEC standardisation.
Those intending to use this software module in products are advised that its
use may infringe existing patents. ISO/IEC have no liability for use of this
software module or modifications thereof. Copyright is not released for
products that do not conform to audiovisual and image-coding related ITU
Recommendations and/or ISO/IEC International Standards.
The original developer retains full right to modify and use the code for its
own purpose, assign or donate the code to a third party and to inhibit third
parties from using the code for products that do not conform to audiovisual and
image-coding related ITU Recommendations and/or ISO/IEC International Standards.
This copyright notice must be included in all copies or derivative works.
Copyright (c) ISO/IEC 2002.
------------------------------------------------------------------------------
PSEUDO-CODE
------------------------------------------------------------------------------
*/
#ifdef AAC_PLUS
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "calc_sbr_synfilterbank.h"
#include "qmf_filterbank_coeff.h"
#include "synthesis_sub_band.h"
#include "fxp_mul32.h"
#include "aac_mem_funcs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
#if defined (PV_ARM_V5)
__inline Int16 sat(Int32 y)
{
Int32 x;
__asm
{
qdadd y, y, y
mov y, y, asr #16
}
return((Int16)y);
}
#define saturate2( a, b, c, d) *c = sat( a); \
*d = sat( b); \
c += 2; \
d -= 2;
#elif defined (PV_ARM_V4)
__inline Int16 sat(Int32 y)
{
Int32 x;
Int32 z = 31; /* rvct compiler problem */
__asm
{
sub y, y, y, asr 2
mov y, y, asr N
mov x, y, asr #15
teq x, y, asr z
eorne y, INT16_MAX, y, asr #31
}
return((Int16)y);
}
#define saturate2( a, b, c, d) *c = sat( a); \
*d = sat( b); \
c += 2; \
d -= 2;
#elif defined(PV_ARM_GCC_V5)
__inline Int16 sat(Int32 y)
{
register Int32 x;
register Int32 ra = y;
asm volatile(
"qdadd %0, %1, %1\n\t"
"mov %0, %0, asr #16"
: "=&r*i"(x)
: "r"(ra));
return ((Int16)x);
}
#define saturate2( a, b, c, d) *c = sat( a); \
*d = sat( b); \
c += 2; \
d -= 2;
#elif defined(PV_ARM_MSC_EVC_V5)
#include "armintr.h"
#define saturate2( a, b, c, d) *c = _DAddSatInt( a, a)>>16; \
*d = _DAddSatInt( b, b)>>16; \
c += 2; \
d -= 2;
#else
#define saturate2( a, b, c, d) a -= (a>>2); \
a = (a>>N); \
if((a>>15) != (a>>31)) \
{ \
a = ((a >> 31) ^ INT16_MAX); \
} \
*c = (Int16)a; \
c += 2; \
b -= (b>>2); \
b = (b>>N); \
if((b>>15) != (b>>31)) \
{ \
b = ((b >> 31) ^ INT16_MAX); \
} \
*d = (Int16)b; \
d -= 2;
#endif
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
void calc_sbr_synfilterbank_LC(Int32 * Sr,
Int16 * timeSig,
Int16 V[1280],
bool bDownSampleSBR)
{
Int32 i;
Int32 realAccu1;
Int32 realAccu2;
const Int32 *pt_C2;
Int16 *pt_V1;
Int16 *pt_V2;
Int16 *pt_timeSig;
Int16 *pt_timeSig_2;
Int32 test1;
Int16 tmp1;
Int16 tmp2;
/* shift filterstates */
Int32 * pt_Sr = Sr;
if (bDownSampleSBR == false)
{
synthesis_sub_band_LC(pt_Sr, V);
/* content of V[] is at most 16 bits */
pt_timeSig = &timeSig[0];
pt_timeSig_2 = &timeSig[64];
tmp1 = V[ 704];
tmp2 = V[ 768];
realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(0.853738560F), ROUND_SYNFIL);
realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(-0.361158990F), realAccu1);
tmp1 = -V[ 512];
tmp2 = V[ 960];
realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(-0.361158990F), realAccu1);
realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(0.070353307F), realAccu1);
tmp1 = V[ 448];
tmp2 = V[1024];
realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(0.070353307F), realAccu1);
realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(-0.013271822F), realAccu1);
tmp1 = -V[ 256];
tmp2 = V[ 192];
realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(-0.013271822F), realAccu1);
realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(0.002620176F), realAccu1);
realAccu1 = fxp_mac_16_by_16(V[1216], Qfmt(0.002620176F), realAccu1);
tmp1 = V[ 32];
tmp2 = V[1248];
realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(-0.000665042F), ROUND_SYNFIL);
realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(-0.000665042F), realAccu2);
tmp1 = V[ 224];
tmp2 = V[1056];
realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.005271576F), realAccu2);
realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.005271576F), realAccu2);
tmp1 = V[ 992];
tmp2 = V[ 288];
realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.058591568F), realAccu2);
realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.058591568F), realAccu2);
tmp1 = V[ 480];
tmp2 = V[ 800];
realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(-0.058370533F), realAccu2);
realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(-0.058370533F), realAccu2);
tmp1 = V[ 736];
tmp2 = V[ 544];
realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.702238872F), realAccu2);
realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.702238872F), realAccu2);
saturate2(realAccu1, realAccu2, pt_timeSig, pt_timeSig_2);
pt_timeSig_2 = &timeSig[126];
pt_V1 = &V[1];
pt_V2 = &V[1279];
pt_C2 = &sbrDecoderFilterbankCoefficients[0];
for (i = 31; i != 0; i--)
{
test1 = *(pt_C2++);
tmp1 = *(pt_V1++);
tmp2 = *(pt_V2--);
realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, ROUND_SYNFIL);
realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, ROUND_SYNFIL);
tmp1 = pt_V1[ 191];
tmp2 = pt_V2[ -191];
realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
test1 = *(pt_C2++);
tmp1 = pt_V1[ 255];
tmp2 = pt_V2[ -255];
realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
tmp1 = pt_V1[ 447];
tmp2 = pt_V2[ -447];
realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
test1 = *(pt_C2++);
tmp1 = pt_V1[ 511];
tmp2 = pt_V2[ -511];
realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
tmp1 = pt_V1[ 703];
tmp2 = pt_V2[ -703];
realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
test1 = *(pt_C2++);
tmp1 = pt_V1[ 767];
tmp2 = pt_V2[ -767];
realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
tmp1 = pt_V1[ 959];
tmp2 = pt_V2[ -959];
realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
test1 = *(pt_C2++);
tmp1 = pt_V1[ 1023];
tmp2 = pt_V2[ -1023];
realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
tmp1 = pt_V1[ 1215];
tmp2 = pt_V2[ -1215];
realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
saturate2(realAccu1, realAccu2, pt_timeSig, pt_timeSig_2);
}
}
else
{
synthesis_sub_band_LC_down_sampled(Sr, V);
/*
* window signal
* calculate output samples
*/
pt_V1 = &V[0];
pt_V2 = &V[96];
Int32 * pt_out = Sr;
for (i = 0; i < 8; i++)
{
*(pt_out++) = 0;
*(pt_out++) = 0;
*(pt_out++) = 0;
*(pt_out++) = 0;
}
const Int32* pt_C1 = &sbrDecoderFilterbankCoefficients_down_smpl[0];
pt_C2 = &sbrDecoderFilterbankCoefficients_down_smpl[16];
for (int k = 0; k < 5; k++)
{
pt_out -= 32;
for (i = 0; i < 16; i++)
{
realAccu1 = fxp_mul_16_by_16bt(*(pt_V1++), *(pt_C1));
realAccu2 = fxp_mul_16_by_16bb(*(pt_V1++), *(pt_C1++));
realAccu1 = fxp_mac_16_by_16_bt(*(pt_V2++), *(pt_C2), realAccu1);
realAccu2 = fxp_mac_16_by_16_bb(*(pt_V2++), *(pt_C2++), realAccu2);
*(pt_out++) += realAccu1 >> 5;
*(pt_out++) += realAccu2 >> 5;
}
pt_V1 += 96;
pt_V2 += 96;
pt_C1 += 16;
pt_C2 += 16;
}
pt_out -= 32;
for (i = 0; i < 32; i++)
{
timeSig[2*i] = (Int16)((*(pt_out++) + 512) >> 10);
}
}
}
#ifdef HQ_SBR
void calc_sbr_synfilterbank(Int32 * Sr,
Int32 * Si,
Int16 * timeSig,
Int16 V[1280],
bool bDownSampleSBR)
{
Int32 i;
const Int32 *pt_C2;
Int32 realAccu1;
Int32 realAccu2;
Int16 *pt_V1;
Int16 *pt_V2;
Int16 *pt_timeSig;
Int16 *pt_timeSig_2;
Int32 test1;
Int16 tmp1;
Int16 tmp2;
if (bDownSampleSBR == false)
{
synthesis_sub_band(Sr, Si, V);
/* content of V[] is at most 16 bits */
pt_timeSig = &timeSig[0];
pt_timeSig_2 = &timeSig[64];
tmp1 = V[ 704];
tmp2 = V[ 768];
realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(0.853738560F), ROUND_SYNFIL);
realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(-0.361158990F), realAccu1);
tmp1 = -V[ 512];
tmp2 = V[ 960];
realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(-0.361158990F), realAccu1);
realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(0.070353307F), realAccu1);
tmp1 = V[ 448];
tmp2 = V[1024];
realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(0.070353307F), realAccu1);
realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(-0.013271822F), realAccu1);
tmp1 = -V[ 256];
tmp2 = V[ 192];
realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(-0.013271822F), realAccu1);
realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(0.002620176F), realAccu1);
realAccu1 = fxp_mac_16_by_16(V[1216], Qfmt(0.002620176F), realAccu1);
tmp1 = V[ 32];
tmp2 = V[1248];
realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(-0.000665042F), ROUND_SYNFIL);
realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(-0.000665042F), realAccu2);
tmp1 = V[ 224];
tmp2 = V[1056];
realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.005271576F), realAccu2);
realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.005271576F), realAccu2);
tmp1 = V[ 992];
tmp2 = V[ 288];
realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.058591568F), realAccu2);
realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.058591568F), realAccu2);
tmp1 = V[ 480];
tmp2 = V[ 800];
realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(-0.058370533F), realAccu2);
realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(-0.058370533F), realAccu2);
tmp1 = V[ 736];
tmp2 = V[ 544];
realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.702238872F), realAccu2);
realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.702238872F), realAccu2);
saturate2(realAccu1, realAccu2, pt_timeSig, pt_timeSig_2);
pt_timeSig_2 = &timeSig[126];
pt_V1 = &V[1];
pt_V2 = &V[1279];
pt_C2 = &sbrDecoderFilterbankCoefficients[0];
for (i = 31; i != 0; i--)
{
test1 = *(pt_C2++);
tmp1 = *(pt_V1++);
tmp2 = *(pt_V2--);
realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, ROUND_SYNFIL);
realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, ROUND_SYNFIL);
tmp1 = pt_V1[ 191];
tmp2 = pt_V2[ -191];
realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
test1 = *(pt_C2++);
tmp1 = pt_V1[ 255];
tmp2 = pt_V2[ -255];
realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
tmp1 = pt_V1[ 447];
tmp2 = pt_V2[ -447];
realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
test1 = *(pt_C2++);
tmp1 = pt_V1[ 511];
tmp2 = pt_V2[ -511];
realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
tmp1 = pt_V1[ 703];
tmp2 = pt_V2[ -703];
realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
test1 = *(pt_C2++);
tmp1 = pt_V1[ 767];
tmp2 = pt_V2[ -767];
realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
tmp1 = pt_V1[ 959];
tmp2 = pt_V2[ -959];
realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
test1 = *(pt_C2++);
tmp1 = pt_V1[ 1023];
tmp2 = pt_V2[ -1023];
realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
tmp1 = pt_V1[ 1215];
tmp2 = pt_V2[ -1215];
realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
saturate2(realAccu1, realAccu2, pt_timeSig, pt_timeSig_2);
}
}
else
{
synthesis_sub_band_down_sampled(Sr, Si, V);
Int32 * pt_out = Sr;
for (i = 0; i < 8; i++)
{
*(pt_out++) = 0;
*(pt_out++) = 0;
*(pt_out++) = 0;
*(pt_out++) = 0;
}
/*
* window signal
* calculate output samples
*/
pt_V1 = &V[0];
pt_V2 = &V[96];
const Int32* pt_C1 = &sbrDecoderFilterbankCoefficients_down_smpl[0];
pt_C2 = &sbrDecoderFilterbankCoefficients_down_smpl[16];
for (Int k = 0; k < 5; k++)
{
pt_out -= 32;
for (i = 0; i < 16; i++)
{
realAccu1 = fxp_mul_16_by_16bt(*(pt_V1++), *(pt_C1));
realAccu2 = fxp_mul_16_by_16bb(*(pt_V1++), *(pt_C1++));
realAccu1 = fxp_mac_16_by_16_bt(*(pt_V2++), *(pt_C2), realAccu1);
realAccu2 = fxp_mac_16_by_16_bb(*(pt_V2++), *(pt_C2++), realAccu2);
*(pt_out++) += realAccu1 >> 5;
*(pt_out++) += realAccu2 >> 5;
}
pt_V1 += 96;
pt_V2 += 96;
pt_C1 += 16;
pt_C2 += 16;
}
pt_out -= 32;
for (i = 0; i < 32; i++)
{
timeSig[2*i] = (Int16)((*(pt_out++) + 512) >> 10);
}
}
}
#endif /* --- HQ_SBR --- */
#endif /* --- AAC_PLUS --- */

View File

@@ -0,0 +1,94 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef CALC_SBR_SYNFILTERBANK_H
#define CALC_SBR_SYNFILTERBANK_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
{
#endif
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
#define N 14
#define ROUND_SYNFIL (32768 + 4096)
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
void calc_sbr_synfilterbank_LC(Int32 * Sr,
Int16 * timeSig,
Int16 V[1280],
bool bDownSampleSBR);
#ifdef HQ_SBR
void calc_sbr_synfilterbank(Int32 * Sr,
Int32 * Si,
Int16 * timeSig,
Int16 V[1280],
bool bDownSampleSBR);
#endif
#ifdef __cplusplus
}
#endif
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -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.
* -------------------------------------------------------------------
*/
/*
Pathname: chans.h
------------------------------------------------------------------------------
REVISION HISTORY
Description: Placed file in the correct template format.
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef CHANS_H
#define CHANS_H
#ifdef __cplusplus
extern "C"
{
#endif
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/* #define is required in order to use these args in #if () directive */
#define ICChans 0
#define DCChans 0
#define XCChans 0
#define CChans 0
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
enum
{
/*
* channels for 5.1 main profile configuration
* (modify for any desired decoder configuration)
*/
FChans = 2, /* front channels: left, center, right */
FCenter = 0, /* 1 if decoder has front center channel */
SChans = 0, /* side channels: */
BChans = 0, /* back channels: left surround, right surround */
BCenter = 0, /* 1 if decoder has back center channel */
LChans = 0, /* LFE channels */
XChans = 0, /* scratch space for parsing unused channels */
Chans = FChans + SChans + BChans + LChans + XChans
};
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
#ifdef __cplusplus
}
#endif
#endif /* CHANS_H */

View File

@@ -0,0 +1,144 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: check_crc.c
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
INPUT
OUTPUT
errorCode, noError if successful
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
------------------------------------------------------------------------------
REQUIREMENTS
------------------------------------------------------------------------------
REFERENCES
SC 29 Software Copyright Licencing Disclaimer:
This software module was originally developed by
Coding Technologies
and edited by
-
in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
standards for reference purposes and its performance may not have been
optimized. This software module is an implementation of one or more tools as
specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
ISO/IEC gives users free license to this software module or modifications
thereof for use in products claiming conformance to audiovisual and
image-coding related ITU Recommendations and/or ISO/IEC International
Standards. ISO/IEC gives users the same free license to this software module or
modifications thereof for research purposes and further ISO/IEC standardisation.
Those intending to use this software module in products are advised that its
use may infringe existing patents. ISO/IEC have no liability for use of this
software module or modifications thereof. Copyright is not released for
products that do not conform to audiovisual and image-coding related ITU
Recommendations and/or ISO/IEC International Standards.
The original developer retains full right to modify and use the code for its
own purpose, assign or donate the code to a third party and to inhibit third
parties from using the code for products that do not conform to audiovisual and
image-coding related ITU Recommendations and/or ISO/IEC International Standards.
This copyright notice must be included in all copies or derivative works.
Copyright (c) ISO/IEC 2002.
------------------------------------------------------------------------------
PSEUDO-CODE
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "check_crc.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
void check_crc(HANDLE_CRC hCrcBuf, UInt32 bValue, Int32 nBits)
{
Int32 i;
UInt32 bMask = (1UL << (nBits - 1));
for (i = 0; i < nBits; i++, bMask >>= 1)
{
UInt16 flag = (UInt16)((hCrcBuf->crcState & hCrcBuf->crcMask) ? 1 : 0);
UInt16 flag1 = (UInt16)((bMask & bValue) ? 1 : 0);
flag ^= flag1;
hCrcBuf->crcState <<= 1;
if (flag)
hCrcBuf->crcState ^= hCrcBuf->crcPoly;
}
}

View File

@@ -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: check_crc.h
Funtions:
get_dse
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
SC 29 Software Copyright Licencing Disclaimer:
This software module was originally developed by
Coding Technologies
and edited by
-
in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
standards for reference purposes and its performance may not have been
optimized. This software module is an implementation of one or more tools as
specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
ISO/IEC gives users free license to this software module or modifications
thereof for use in products claiming conformance to audiovisual and
image-coding related ITU Recommendations and/or ISO/IEC International
Standards. ISO/IEC gives users the same free license to this software module or
modifications thereof for research purposes and further ISO/IEC standardisation.
Those intending to use this software module in products are advised that its
use may infringe existing patents. ISO/IEC have no liability for use of this
software module or modifications thereof. Copyright is not released for
products that do not conform to audiovisual and image-coding related ITU
Recommendations and/or ISO/IEC International Standards.
The original developer retains full right to modify and use the code for its
own purpose, assign or donate the code to a third party and to inhibit third
parties from using the code for products that do not conform to audiovisual and
image-coding related ITU Recommendations and/or ISO/IEC International Standards.
This copyright notice must be included in all copies or derivative works.
Copyright (c) ISO/IEC 2002.
$Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef CHECK_CRC_H
#define CHECK_CRC_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "s_crc_buffer.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
{
#endif
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
void check_crc(HANDLE_CRC hCrcBuf,
UInt32 bValue,
Int32 nBits);
#ifdef __cplusplus
}
#endif
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,266 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: dct16.c
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Int32 x 32-bit integer input length 16
Int32 flag 1 forward dct16, 0 modified dct-16
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
Implement dct of lenght 16
------------------------------------------------------------------------------
REQUIREMENTS
------------------------------------------------------------------------------
REFERENCES
------------------------------------------------------------------------------
PSEUDO-CODE
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#ifdef AAC_PLUS
#include "dct16.h"
#include "fxp_mul32.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
#define Qfmt_31(a) (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F))
#define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F))
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
void dct_16(Int32 vec[], Int flag)
{
Int32 tmp0;
Int32 tmp1;
Int32 tmp2;
Int32 tmp3;
Int32 tmp4;
Int32 tmp5;
Int32 tmp6;
Int32 tmp7;
Int32 tmp_o0;
Int32 tmp_o1;
Int32 tmp_o2;
Int32 tmp_o3;
Int32 tmp_o4;
Int32 tmp_o5;
Int32 tmp_o6;
Int32 tmp_o7;
Int32 itmp_e0;
Int32 itmp_e1;
Int32 itmp_e2;
/* split input vector */
tmp_o0 = fxp_mul32_by_16((vec[ 0] - vec[15]), Qfmt15(0.50241928618816F));
tmp0 = vec[ 0] + vec[15];
tmp_o7 = fxp_mul32_Q31((vec[ 7] - vec[ 8]) << 3, Qfmt_31(0.63764357733614F));
tmp7 = vec[ 7] + vec[ 8];
itmp_e0 = (tmp0 + tmp7);
tmp7 = fxp_mul32_by_16((tmp0 - tmp7), Qfmt15(0.50979557910416F));
tmp_o1 = fxp_mul32_by_16((vec[ 1] - vec[14]), Qfmt15(0.52249861493969F));
tmp1 = vec[ 1] + vec[14];
tmp_o6 = fxp_mul32_by_16((vec[ 6] - vec[ 9]) << 1, Qfmt15(0.86122354911916F));
tmp6 = vec[ 6] + vec[ 9];
itmp_e1 = (tmp1 + tmp6);
tmp6 = fxp_mul32_by_16((tmp1 - tmp6), Qfmt15(0.60134488693505F));
tmp_o2 = fxp_mul32_by_16((vec[ 2] - vec[13]), Qfmt15(0.56694403481636F));
tmp2 = vec[ 2] + vec[13];
tmp_o5 = fxp_mul32_by_16((vec[ 5] - vec[10]) << 1, Qfmt15(0.53033884299517F));
tmp5 = vec[ 5] + vec[10];
itmp_e2 = (tmp2 + tmp5);
tmp5 = fxp_mul32_by_16((tmp2 - tmp5), Qfmt15(0.89997622313642F));
tmp_o3 = fxp_mul32_by_16((vec[ 3] - vec[12]), Qfmt15(0.64682178335999F));
tmp3 = vec[ 3] + vec[12];
tmp_o4 = fxp_mul32_by_16((vec[ 4] - vec[11]), Qfmt15(0.78815462345125F));
tmp4 = vec[ 4] + vec[11];
tmp1 = (tmp3 + tmp4);
tmp4 = fxp_mul32_Q31((tmp3 - tmp4) << 2, Qfmt_31(0.64072886193538F));
/* split even part of tmp_e */
tmp0 = (itmp_e0 + tmp1);
tmp1 = fxp_mul32_by_16((itmp_e0 - tmp1), Qfmt15(0.54119610014620F));
tmp3 = fxp_mul32_by_16((itmp_e1 - itmp_e2) << 1, Qfmt15(0.65328148243819F));
tmp2 = (itmp_e1 + itmp_e2);
vec[ 0] = (tmp0 + tmp2) >> 1;
vec[ 8] = fxp_mul32_by_16((tmp0 - tmp2), Qfmt15(0.70710678118655F));
vec[12] = fxp_mul32_by_16((tmp1 - tmp3) << 1, Qfmt15(0.70710678118655F));
vec[ 4] = tmp1 + tmp3;
vec[ 4] += vec[12];
/* split odd part of tmp_e */
tmp1 = fxp_mul32_by_16((tmp7 - tmp4) << 1, Qfmt15(0.54119610014620F));
tmp7 += tmp4;
tmp3 = fxp_mul32_Q31((tmp6 - tmp5) << 2, Qfmt_31(0.65328148243819F));
tmp6 += tmp5;
vec[10] = fxp_mul32_by_16((tmp7 - tmp6) << 1, Qfmt15(0.70710678118655F));
vec[ 2] = tmp7 + tmp6;
vec[14] = fxp_mul32_by_16((tmp1 - tmp3) << 1, Qfmt15(0.70710678118655F));
tmp1 += tmp3 + vec[14];
vec[ 2] += tmp1;
vec[ 6] = tmp1 + vec[10];
vec[10] += vec[14];
// dct8;
tmp7 = tmp_o0 + tmp_o7;
tmp_o7 = fxp_mul32_by_16((tmp_o0 - tmp_o7) << 1, Qfmt15(0.50979557910416F));
tmp6 = tmp_o1 + tmp_o6;
tmp_o1 = fxp_mul32_by_16((tmp_o1 - tmp_o6) << 1, Qfmt15(0.60134488693505F));
tmp5 = tmp_o2 + tmp_o5;
tmp_o5 = fxp_mul32_by_16((tmp_o2 - tmp_o5) << 1, Qfmt15(0.89997622313642F));
tmp4 = tmp_o3 + tmp_o4;
tmp_o3 = fxp_mul32_Q31((tmp_o3 - tmp_o4) << 3, Qfmt_31(0.6407288619354F));
if (!flag)
{
tmp7 = -tmp7;
tmp_o7 = -tmp_o7;
tmp6 = -tmp6;
tmp_o1 = -tmp_o1;
tmp5 = -tmp5;
tmp_o5 = -tmp_o5;
tmp4 = -tmp4;
tmp_o3 = -tmp_o3;
}
// even part
tmp1 = fxp_mul32_by_16((tmp7 - tmp4) << 1, Qfmt15(0.54119610014620F));
tmp0 = tmp7 + tmp4;
tmp3 = fxp_mul32_Q31((tmp6 - tmp5) << 2, Qfmt_31(0.65328148243819F));
tmp2 = tmp6 + tmp5;
vec[ 9] = fxp_mul32_Q31((tmp0 - tmp2) << 1, Qfmt_31(0.70710678118655F));
vec[ 1] = tmp0 + tmp2;
vec[13] = fxp_mul32_Q31((tmp1 - tmp3) << 1, Qfmt_31(0.70710678118655F));
vec[ 5] = tmp1 + tmp3 + vec[13];
// odd part
tmp0 = tmp_o7 + tmp_o3;
tmp1 = fxp_mul32_by_16((tmp_o7 - tmp_o3) << 1, Qfmt15(0.54119610014620F));
tmp2 = tmp_o1 + tmp_o5;
tmp3 = fxp_mul32_Q31((tmp_o1 - tmp_o5) << 2, Qfmt_31(0.65328148243819F));
vec[11] = fxp_mul32_Q31((tmp0 - tmp2) << 1, Qfmt_31(0.70710678118655F));
vec[ 3] = tmp0 + tmp2;
vec[15] = fxp_mul32_Q31((tmp1 - tmp3) << 1, Qfmt_31(0.70710678118655F));
vec[ 7] = tmp1 + tmp3 + vec[15];
vec[ 3] += vec[ 7];
vec[ 7] += vec[11];
vec[11] += vec[15];
vec[ 1] += vec[ 3];
vec[ 3] += vec[ 5];
vec[ 5] += vec[ 7];
vec[ 7] += vec[ 9];
vec[ 9] += vec[11];
vec[11] += vec[13];
vec[13] += vec[15];
}
#endif

View File

@@ -0,0 +1,68 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./c/include/dct16.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
------------------------------------------------------------------------------
*/
#ifndef DCT16_H
#define DCT16_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
{
#endif
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES AND SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
void dct_16(Int32 vec[], Int flag);
#ifdef __cplusplus
}
#endif
#endif /* DCT16_H */

View File

@@ -0,0 +1,569 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: dct64.c
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Int32 x 32-bit integer input length 64
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
Implement dct of lenght 64
------------------------------------------------------------------------------
REQUIREMENTS
------------------------------------------------------------------------------
REFERENCES
------------------------------------------------------------------------------
PSEUDO-CODE
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#ifdef AAC_PLUS
#include "dct16.h"
#include "dct64.h"
#include "pv_audio_type_defs.h"
#include "synthesis_sub_band.h"
#include "fxp_mul32.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
#define Qfmt(a) (Int32)(a*((Int32)1<<26) + (a>=0?0.5F:-0.5F))
#define Qfmt31(a) (Int32)(a*0x7FFFFFFF)
const Int32 CosTable_48[48] =
{
Qfmt31(0.50015063602065F) , Qfmt31(0.50135845244641F) ,
Qfmt31(0.50378872568104F) , Qfmt31(0.50747117207256F) ,
Qfmt31(0.51245147940822F) , Qfmt31(0.51879271310533F) ,
Qfmt31(0.52657731515427F) , Qfmt31(0.53590981690799F) ,
Qfmt31(0.54692043798551F) , Qfmt31(0.55976981294708F) ,
Qfmt31(0.57465518403266F) , Qfmt31(0.59181853585742F) ,
Qfmt31(0.61155734788251F) , Qfmt31(0.63423893668840F) ,
Qfmt31(0.66031980781371F) , Qfmt31(0.69037212820021F) ,
Qfmt31(0.72512052237720F) , Qfmt31(0.76549416497309F) ,
Qfmt31(0.81270209081449F) , Qfmt31(0.86834471522335F) ,
Qfmt(0.93458359703641F) , Qfmt(1.01440826499705F) ,
Qfmt(1.11207162057972F) , Qfmt(1.23383273797657F) ,
Qfmt(1.38929395863283F) , Qfmt(1.59397228338563F) ,
Qfmt(1.87467598000841F) , Qfmt(2.28205006800516F) ,
Qfmt(2.92462842815822F) , Qfmt(4.08461107812925F) ,
Qfmt(6.79675071167363F) , Qfmt(20.37387816723145F) , /* 32 */
Qfmt(0.50060299823520F) , Qfmt(0.50547095989754F) ,
Qfmt(0.51544730992262F) , Qfmt(0.53104259108978F) ,
Qfmt(0.55310389603444F) , Qfmt(0.58293496820613F) ,
Qfmt(0.62250412303566F) , Qfmt(0.67480834145501F) ,
Qfmt(0.74453627100230F) , Qfmt(0.83934964541553F) ,
Qfmt(0.97256823786196F) , Qfmt(1.16943993343288F) ,
Qfmt(1.48416461631417F) , Qfmt(2.05778100995341F) ,
Qfmt(3.40760841846872F) , Qfmt(10.19000812354803F)
};
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; dct_64
----------------------------------------------------------------------------*/
void pv_split_LC(Int32 *vector,
Int32 *temp_o)
{
Int32 i;
Int32 *pt_vector = &vector[0];
Int32 *pt_vector_N_1 = &vector[31];
const Int32 *pt_cosTerms = &CosTable_48[32];
Int32 *pt_temp_o = temp_o;
Int32 tmp1;
Int32 tmp2;
Int32 tmp3;
tmp1 = *(pt_vector);
tmp2 = *(pt_vector_N_1--);
for (i = 16; i != 0; i--)
{
tmp3 = *(pt_cosTerms++);
*(pt_vector++) = tmp1 + tmp2;
*(pt_temp_o++) = fxp_mul32_Q26((tmp1 - tmp2), tmp3);
tmp1 = *(pt_vector);
tmp2 = *(pt_vector_N_1--);
}
}
#ifdef HQ_SBR
void dct_64(Int32 vec[], Int32 *scratch_mem)
{
Int32 *temp_e1;
Int32 *temp_o1;
Int32 *pt_vec;
Int i;
Int32 aux1;
Int32 aux2;
Int32 aux3;
Int32 aux4;
const Int32 *cosTerms = &CosTable_48[31];
temp_o1 = &vec[32];
temp_e1 = temp_o1 - 1;
for (i = 6; i != 0; i--)
{
aux1 = *(temp_e1);
aux2 = *(temp_o1);
aux3 = *(cosTerms--);
*(temp_e1--) = aux1 + aux2;
*(temp_o1++) = fxp_mul32_Q26((aux1 - aux2), aux3);
aux1 = *(temp_e1);
aux2 = *(temp_o1);
aux3 = *(cosTerms--);
*(temp_e1--) = aux1 + aux2;
*(temp_o1++) = fxp_mul32_Q26((aux1 - aux2), aux3);
}
for (i = 10; i != 0; i--)
{
aux1 = *(temp_e1);
aux2 = *(temp_o1);
aux3 = *(cosTerms--);
*(temp_e1--) = aux1 + aux2;
*(temp_o1++) = fxp_mul32_Q31((aux1 - aux2), aux3) << 1;
aux1 = *(temp_e1);
aux2 = *(temp_o1);
aux3 = *(cosTerms--);
*(temp_e1--) = aux1 + aux2;
*(temp_o1++) = fxp_mul32_Q31((aux1 - aux2), aux3) << 1;
}
pv_split(&vec[16]);
dct_16(&vec[16], 0);
dct_16(vec, 1); // Even terms
pv_merge_in_place_N32(vec);
pv_split_z(&vec[32]);
dct_16(&vec[32], 1); // Even terms
dct_16(&vec[48], 0);
pv_merge_in_place_N32(&vec[32]);
aux1 = vec[32];
aux3 = vec[33];
aux4 = vec[ 1]; /* vec[ 1] */
/* -----------------------------------*/
aux1 = vec[32] + vec[33];
vec[ 0] += aux1;
vec[ 1] += aux1;
aux1 = vec[34];
aux2 = vec[ 2]; /* vec[ 2] */
aux3 += aux1;
vec[ 2] = aux4 + aux3;
aux4 = vec[ 3]; /* vec[ 3] */
vec[ 3] = aux2 + aux3;
aux3 = vec[35];
/* -----------------------------------*/
aux1 += aux3;
vec[32] = vec[ 4];
vec[33] = vec[ 5];
vec[ 4] = aux2 + aux1;
vec[ 5] = aux4 + aux1;
aux1 = vec[36];
aux2 = vec[32]; /* vec[ 4] */
aux3 += aux1;
vec[34] = vec[ 6];
vec[35] = vec[ 7];
vec[ 6] = aux4 + aux3;
vec[ 7] = aux2 + aux3;
aux3 = vec[37];
aux4 = vec[33]; /* vec[ 5] */
/* -----------------------------------*/
aux1 += aux3;
vec[32] = vec[ 8];
vec[33] = vec[ 9];
vec[ 8] = aux2 + aux1;
vec[ 9] = aux4 + aux1;
aux1 = vec[38];
aux2 = vec[34]; /* vec[ 6] */
aux3 += aux1;
vec[34] = vec[10];
vec[10] = aux4 + aux3;
aux4 = vec[35]; /* vec[ 7] */
vec[35] = vec[11];
vec[11] = aux2 + aux3;
aux3 = vec[39];
/* -----------------------------------*/
aux1 += aux3;
vec[36] = vec[12];
vec[37] = vec[13];
vec[12] = aux2 + aux1;
vec[13] = aux4 + aux1;
aux1 = vec[40];
aux2 = vec[32]; /* vec[ 8] */
aux3 += aux1;
vec[32] = vec[14];
vec[14] = aux4 + aux3;
aux4 = vec[33]; /* vec[ 9] */
vec[33] = vec[15];
vec[15] = aux2 + aux3;
aux3 = vec[41];
/* -----------------------------------*/
aux1 += aux3;
vec[38] = vec[16];
vec[39] = vec[17];
vec[16] = aux2 + aux1;
vec[17] = aux4 + aux1;
aux1 = vec[42];
aux2 = vec[34]; /* vec[10] */
aux3 += aux1;
vec[34] = vec[18];
vec[18] = aux4 + aux3;
aux4 = vec[35]; /* vec[11] */
vec[35] = vec[19];
vec[19] = aux2 + aux3;
aux3 = vec[43];
/* -----------------------------------*/
aux1 += aux3;
vec[40] = vec[20];
vec[41] = vec[21];
vec[20] = aux2 + aux1;
vec[21] = aux4 + aux1;
aux1 = vec[44];
aux2 = vec[36]; /* vec[12] */
aux3 += aux1;
vec[42] = vec[22];
vec[43] = vec[23];
vec[22] = aux4 + aux3;
vec[23] = aux2 + aux3;
aux3 = vec[45];
aux4 = vec[37]; /* vec[13] */
/* -----------------------------------*/
scratch_mem[0] = vec[24];
scratch_mem[1] = vec[25];
aux1 += aux3;
vec[24] = aux2 + aux1;
vec[25] = aux4 + aux1;
aux1 = vec[46];
aux2 = vec[32]; /* vec[14] */
scratch_mem[2] = vec[26];
scratch_mem[3] = vec[27];
aux3 += aux1;
vec[26] = aux4 + aux3;
vec[27] = aux2 + aux3;
aux3 = vec[47];
aux4 = vec[33]; /* vec[15] */
/* -----------------------------------*/
scratch_mem[4] = vec[28];
scratch_mem[5] = vec[29];
aux1 += aux3;
vec[28] = aux2 + aux1;
vec[29] = aux4 + aux1;
aux1 = vec[48];
aux2 = vec[38]; /* vec[16] */
scratch_mem[6] = vec[30];
scratch_mem[7] = vec[31];
aux3 += aux1;
vec[30] = aux4 + aux3;
vec[31] = aux2 + aux3;
aux3 = vec[49];
aux4 = vec[39]; /* vec[17] */
/* -----------------------------------*/
aux1 += aux3;
vec[32] = aux2 + aux1;
vec[33] = aux4 + aux1;
aux1 = vec[50];
aux2 = vec[34]; /* vec[18] */
aux3 += aux1;
vec[34] = aux4 + aux3;
aux4 = vec[35]; /* vec[19] */
vec[35] = aux2 + aux3;
aux3 = vec[51];
/* -----------------------------------*/
aux1 += aux3;
vec[36] = aux2 + aux1;
vec[37] = aux4 + aux1;
aux1 = vec[52];
aux2 = vec[40]; /* vec[20] */
aux3 += aux1;
vec[38] = aux4 + aux3;
vec[39] = aux2 + aux3;
aux3 = vec[53];
aux4 = vec[41]; /* vec[21] */
/* -----------------------------------*/
aux1 += aux3;
vec[40] = aux2 + aux1;
vec[41] = aux4 + aux1;
aux1 = vec[54];
aux2 = vec[42]; /* vec[22] */
aux3 += aux1;
vec[42] = aux4 + aux3;
aux4 = vec[43]; /* vec[23] */
vec[43] = aux2 + aux3;
aux3 = vec[55];
/* -----------------------------------*/
pt_vec = &vec[44];
temp_o1 = &vec[56];
temp_e1 = &scratch_mem[0];
for (i = 4; i != 0; i--)
{
aux1 += aux3;
*(pt_vec++) = aux2 + aux1;
*(pt_vec++) = aux4 + aux1;
aux1 = *(temp_o1++);
aux3 += aux1;
aux2 = *(temp_e1++);
*(pt_vec++) = aux4 + aux3;
*(pt_vec++) = aux2 + aux3;
aux3 = *(temp_o1++);
aux4 = *(temp_e1++);
}
aux1 += aux3;
vec[60] = aux2 + aux1;
vec[61] = aux4 + aux1;
vec[62] = aux4 + aux3;
}
#endif
/*----------------------------------------------------------------------------
; pv_split
----------------------------------------------------------------------------*/
void pv_split(Int32 *temp_o)
{
Int32 i;
const Int32 *pt_cosTerms = &CosTable_48[47];
Int32 *pt_temp_o = temp_o;
Int32 *pt_temp_e = pt_temp_o - 1;
Int32 tmp1;
Int32 tmp2;
Int32 cosx;
for (i = 8; i != 0; i--)
{
tmp2 = *(pt_temp_o);
tmp1 = *(pt_temp_e);
cosx = *(pt_cosTerms--);
*(pt_temp_e--) = tmp1 + tmp2;
*(pt_temp_o++) = fxp_mul32_Q26((tmp1 - tmp2), cosx);
tmp1 = *(pt_temp_e);
tmp2 = *(pt_temp_o);
cosx = *(pt_cosTerms--);
*(pt_temp_e--) = tmp1 + tmp2;
*(pt_temp_o++) = fxp_mul32_Q26((tmp1 - tmp2), cosx);
}
}
void pv_split_z(Int32 *vector)
{
Int32 i;
Int32 *pt_vector = &vector[31];
const Int32 *pt_cosTerms = &CosTable_48[32];
Int32 *pt_temp_e = vector;
Int32 tmp1;
Int32 tmp2;
Int32 cosx;
for (i = 8; i != 0; i--)
{
tmp1 = *(pt_vector);
tmp2 = *(pt_temp_e);
cosx = *(pt_cosTerms++);
*(pt_temp_e++) = tmp1 + tmp2;
*(pt_vector--) = fxp_mul32_Q26((tmp1 - tmp2), cosx);
tmp2 = *(pt_temp_e);
tmp1 = *(pt_vector);
cosx = *(pt_cosTerms++);
*(pt_temp_e++) = tmp1 + tmp2;
*(pt_vector--) = fxp_mul32_Q26((tmp1 - tmp2), cosx);
}
}
void pv_merge_in_place_N32(Int32 vec[])
{
Int32 temp[4];
temp[0] = vec[14];
vec[14] = vec[ 7];
temp[1] = vec[12];
vec[12] = vec[ 6];
temp[2] = vec[10];
vec[10] = vec[ 5];
temp[3] = vec[ 8];
vec[ 8] = vec[ 4];
vec[ 6] = vec[ 3];
vec[ 4] = vec[ 2];
vec[ 2] = vec[ 1];
vec[ 1] = vec[16] + vec[17];
vec[16] = temp[3];
vec[ 3] = vec[18] + vec[17];
vec[ 5] = vec[19] + vec[18];
vec[18] = vec[9];
temp[3] = vec[11];
vec[ 7] = vec[20] + vec[19];
vec[ 9] = vec[21] + vec[20];
vec[20] = temp[2];
temp[2] = vec[13];
vec[11] = vec[22] + vec[21];
vec[13] = vec[23] + vec[22];
vec[22] = temp[3];
temp[3] = vec[15];
vec[15] = vec[24] + vec[23];
vec[17] = vec[25] + vec[24];
vec[19] = vec[26] + vec[25];
vec[21] = vec[27] + vec[26];
vec[23] = vec[28] + vec[27];
vec[25] = vec[29] + vec[28];
vec[27] = vec[30] + vec[29];
vec[29] = vec[30] + vec[31];
vec[24] = temp[1];
vec[26] = temp[2];
vec[28] = temp[0];
vec[30] = temp[3];
}
#endif

View File

@@ -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.
* -------------------------------------------------------------------
*/
/*
Pathname: ./c/include/dct64.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
------------------------------------------------------------------------------
*/
#ifndef DCT64_H
#define DCT64_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
{
#endif
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
----------------------------------------------------------------------------*/
extern const Int32 CosTable_48[48];
/*----------------------------------------------------------------------------
; DEFINES AND SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
void pv_split_LC(Int32 *vector,
Int32 *temp_o);
#ifdef HQ_SBR
void dct_64(Int32 vec[], Int32 *scratch_mem);
#endif
void pv_split(Int32 *temp_o);
void pv_split_z(Int32 *vector);
void pv_merge_in_place_N32(Int32 vec[]);
#ifdef __cplusplus
}
#endif
#endif /* DCT64_H */

View File

@@ -0,0 +1,708 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./src/decode_huff_cw_binary.c
Funtions:
decode_huff_cw_tab1
decode_huff_cw_tab2
decode_huff_cw_tab3
decode_huff_cw_tab4
decode_huff_cw_tab5
decode_huff_cw_tab6
decode_huff_cw_tab7
decode_huff_cw_tab8
decode_huff_cw_tab9
decode_huff_cw_tab10
decode_huff_cw_tab11
decode_huff_cw_scl
------------------------------------------------------------------------------
REVISION HISTORY
Description: Updated per review comments
(1) make cw sgined and change "if(cw&0x80000000)" to if(cw<0)
(2)
Description: Create specific functions for different huffman tables.
Description: Added ( Int16) castings to eliminate several compiler warnings
Description: Modified huffman tables to allocate int32 variables instead of
int16, which lead to data missaligned for some compiler.
Eliminated casting and unused variables
Who: Date:
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Inputs:
BITS *pInputStream = pointer to input bit stream
Local Stores/Buffers/Pointers Needed:
Global Stores/Buffers/Pointers Needed:
Outputs:
idx = bit field extracted from a leaf entry of packed Huffman Tables
Pointers and Buffers Modified:
Local Stores Modified:
Global Stores Modified:
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
These functions are used to decode huffman codewords from the input
bitstream using combined binary search and look-up table approach.
First the codewords are grouped and the input symbol is determined
which group it belongs. Then within that group, a look-up table is
used to determine which codeword the symbol is.
The table is created by ordering the codeword in the table according to their
normalized shifted binary value, i.e., all the codewords are left
shifted to meet the maximum codelength. Example, max codelength is
10, the codeword with lenth 3 will left shift by 7.
The binary values of after the shift are sorted.
Then the sorted table is divided into several partition.
At the VLC decoding period, input is read in at max codelenght.
The partition is decided using if-else logic.
Inside each partition, a look-up table is used to map the input value
to a correct symbol. Table entries can appear to be repeated according
to the humming distance between adjacent codewords.
------------------------------------------------------------------------------
REQUIREMENTS
------------------------------------------------------------------------------
REFERENCES
(1) MPEG-2 NBC Audio Decoder
"This software module was originally developed by AT&T, Dolby
Laboratories, Fraunhofer Gesellschaft IIS in the course of development
of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
3. This software module is an implementation of a part of one or more
MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
standards free license to this software module or modifications thereof
for use in hardware or software products claiming conformance to the
MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
module in hardware or software products are advised that this use may
infringe existing patents. The original developer of this software
module and his/her company, the subsequent editors and their companies,
and ISO/IEC have no liability for use of this software module or
modifications thereof in an implementation. Copyright is not released
for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
developer retains full right to use the code for his/her own purpose,
assign or donate the code to a third party and to inhibit third party
from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
This copyright notice must be included in all copies or derivative
works."
Copyright(c)1996.
(2) Introduction to Algorithms,
Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest.
The MIT press, 1990
(3) "Selecting an Optimal Huffman Decoder for AAC",
Vladimir Z. Mesarovic, et al.
AES 111th Convention, September 21-24, 2001, New York, USA
------------------------------------------------------------------------------
PSEUDO-CODE
------------------------------------------------------------------------------
RESOURCES USED
When the code is written for a specific target processor the
the resources used should be documented below.
STACK USAGE:
DATA MEMORY USED: x words
PROGRAM MEMORY USED: x words
CLOCK CYCLES:
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "huffman.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
#define MAX_CW_LEN (19)
#define MASK_IDX (0x1FF)
#define MASK_RIGHT (0xFE00)
#define UPPER16 (16)
#define MASK_LOW16 (0xFFFF)
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
Int decode_huff_cw_tab1(
BITS *pInputStream)
{
Int32 tab;
Int32 cw;
cw = get17_n_lessbits(
11,
pInputStream);
if ((cw >> 10) == 0)
{
pInputStream->usedBits -= (11 - 1);
return 40; /* idx is 40 */
}
else if ((cw >> 6) <= 23)
{
tab = (cw >> 6) - 16;
}
else if ((cw >> 4) <= 119)
{
tab = (cw >> 4) - 96 + 8;
}
else if ((cw >> 2) <= 503)
{
tab = (cw >> 2) - 480 + 32;
}
else
{
tab = cw - 2016 + 56;
}
tab = *(huff_tab1 + tab);
pInputStream->usedBits -= (11 - (tab & MASK_LOW16));
return ((Int)(tab >> UPPER16));
}
Int decode_huff_cw_tab2(
BITS *pInputStream)
{
Int32 tab;
Int32 cw;
cw = get9_n_lessbits(
9,
pInputStream);
if ((cw >> 6) == 0)
{
pInputStream->usedBits -= (9 - 3); /* used 3 bits */
return 40; /* idx is 40 */
}
else if ((cw >> 3) <= 49)
{
tab = (cw >> 3) - 8;
}
else if ((cw >> 2) <= 114)
{
tab = (cw >> 2) - 100 + 42;
}
else if ((cw >> 1) <= 248)
{
tab = (cw >> 1) - 230 + 57;
}
else
{
tab = cw - 498 + 76;
}
tab = *(huff_tab2 + tab);
pInputStream->usedBits -= (9 - (tab & MASK_LOW16));
return ((Int)(tab >> UPPER16));
}
Int decode_huff_cw_tab3(
BITS *pInputStream)
{
Int32 tab;
Int32 cw;
cw = get17_n_lessbits(
16,
pInputStream);
if ((cw >> 15) == 0)
{
pInputStream->usedBits -= (16 - 1); /* used 1 bits */
return 0; /* idx is 0 */
}
else if ((cw >> 10) <= 57)
{
tab = (cw >> 10) - 32;
}
else if ((cw >> 7) <= 500)
{
tab = (cw >> 7) - 464 + 26;
}
else if ((cw >> 6) <= 1016)
{
tab = (cw >> 6) - 1002 + 63;
}
else if ((cw >> 4) <= 4092)
{
tab = (cw >> 4) - 4068 + 78;
}
else
{
tab = cw - 65488 + 103;
}
tab = *(huff_tab3 + tab);
pInputStream->usedBits -= (16 - (tab & MASK_LOW16));
return ((Int)(tab >> UPPER16));
}
Int decode_huff_cw_tab4(
BITS *pInputStream)
{
Int32 tab;
Int32 cw;
cw = get17_n_lessbits(
12,
pInputStream);
if ((cw >> 7) <= 25)
{
tab = (cw >> 7);
}
else if ((cw >> 4) <= 246)
{
tab = (cw >> 4) - 208 + 26;
}
else if ((cw >> 2) <= 1017)
{
tab = (cw >> 2) - 988 + 65;
}
else
{
tab = cw - 4072 + 95;
}
tab = *(huff_tab4 + tab);
pInputStream->usedBits -= (12 - (tab & MASK_LOW16));
return ((Int)(tab >> UPPER16));
}
Int decode_huff_cw_tab5(
BITS *pInputStream)
{
Int32 tab;
Int32 cw;
cw = get17_n_lessbits(
13,
pInputStream);
if ((cw >> 12) == 0)
{
pInputStream->usedBits -= (13 - 1); /* used 1 bits */
return 40; /* idx is 40 */
}
else if ((cw >> 8) <= 27)
{
tab = (cw >> 8) - 16;
}
else if ((cw >> 5) <= 243)
{
tab = (cw >> 5) - 224 + 12;
}
else if ((cw >> 3) <= 1011)
{
tab = (cw >> 3) - 976 + 32;
}
else if ((cw >> 2) <= 2041)
{
tab = (cw >> 2) - 2024 + 68;
}
else
{
tab = cw - 8168 + 86;
}
tab = *(huff_tab5 + tab);
pInputStream->usedBits -= (13 - (tab & MASK_LOW16));
return ((Int)(tab >> UPPER16));
}
Int decode_huff_cw_tab6(
BITS *pInputStream)
{
Int32 tab;
Int32 cw;
cw = get17_n_lessbits(
11,
pInputStream);
if ((cw >> 7) <= 8)
{
tab = (cw >> 7);
}
else if ((cw >> 4) <= 116)
{
tab = (cw >> 4) - 72 + 9;
}
else if ((cw >> 2) <= 506)
{
tab = (cw >> 2) - 468 + 54;
}
else
{
tab = cw - 2028 + 93;
}
tab = *(huff_tab6 + tab);
pInputStream->usedBits -= (11 - (tab & MASK_LOW16));
return ((Int)(tab >> UPPER16));
}
Int decode_huff_cw_tab7(
BITS *pInputStream)
{
Int32 tab;
Int32 cw;
cw = get17_n_lessbits(
12,
pInputStream);
if ((cw >> 11) == 0)
{
pInputStream->usedBits -= (12 - 1); /* used 1 bits */
return 0; /* idx is 0 */
}
else if ((cw >> 6) <= 55)
{
tab = (cw >> 6) - 32;
}
else if ((cw >> 4) <= 243)
{
tab = (cw >> 4) - 224 + 24;
}
else if ((cw >> 2) <= 1018)
{
tab = (cw >> 2) - 976 + 44;
}
else
{
tab = cw - 4076 + 87;
}
tab = *(huff_tab7 + tab);
pInputStream->usedBits -= (12 - (tab & MASK_LOW16));
return ((Int)(tab >> UPPER16));
}
Int decode_huff_cw_tab8(
BITS *pInputStream)
{
Int32 tab;
Int32 cw;
cw = get17_n_lessbits(
10,
pInputStream);
if ((cw >> 5) <= 20)
{
tab = (cw >> 5);
}
else if ((cw >> 3) <= 117)
{
tab = (cw >> 3) - 84 + 21;
}
else if ((cw >> 2) <= 250)
{
tab = (cw >> 2) - 236 + 55;
}
else
{
tab = cw - 1004 + 70;
}
tab = *(huff_tab8 + tab);
pInputStream->usedBits -= (10 - (tab & MASK_LOW16));
return ((Int)(tab >> UPPER16));
}
Int decode_huff_cw_tab9(
BITS *pInputStream)
{
Int32 tab;
Int32 cw;
cw = get17_n_lessbits(
15,
pInputStream);
if ((cw >> 11) <= 12)
{
tab = (cw >> 11);
}
else if ((cw >> 8) <= 114)
{
tab = (cw >> 8) - 104 + 13;
}
else if ((cw >> 6) <= 486)
{
tab = (cw >> 6) - 460 + 24;
}
else if ((cw >> 5) <= 993)
{
tab = (cw >> 5) - 974 + 51;
}
else if ((cw >> 4) <= 2018)
{
tab = (cw >> 4) - 1988 + 71;
}
else if ((cw >> 3) <= 4075)
{
tab = (cw >> 3) - 4038 + 102;
}
else if ((cw >> 2) <= 8183)
{
tab = (cw >> 2) - 8152 + 140;
}
else
{
tab = cw - 32736 + 172;
}
tab = *(huff_tab9 + tab);
pInputStream->usedBits -= (15 - (tab & MASK_LOW16));
return ((Int)(tab >> UPPER16));
}
Int decode_huff_cw_tab10(
BITS *pInputStream)
{
Int32 tab;
Int32 cw;
cw = get17_n_lessbits(
12,
pInputStream);
if ((cw >> 6) <= 41)
{
tab = (cw >> 6);
}
else if ((cw >> 5) <= 100)
{
tab = (cw >> 5) - 84 + 42;
}
else if ((cw >> 4) <= 226)
{
tab = (cw >> 4) - 202 + 59;
}
else if ((cw >> 3) <= 484)
{
tab = (cw >> 3) - 454 + 84;
}
else if ((cw >> 2) <= 1010)
{
tab = (cw >> 2) - 970 + 115;
}
else if ((cw >> 1) <= 2043)
{
tab = (cw >> 1) - 2022 + 156;
}
else
{
tab = cw - 4088 + 178;
}
tab = *(huff_tab10 + tab);
pInputStream->usedBits -= (12 - (tab & MASK_LOW16));
return ((Int)(tab >> UPPER16));
}
Int decode_huff_cw_tab11(
BITS *pInputStream)
{
Int32 tab;
Int32 cw;
cw = get17_n_lessbits(
12,
pInputStream);
if ((cw >> 6) <= 26)
{
tab = (cw >> 6);
}
else if ((cw >> 5) <= 69)
{
tab = (cw >> 5) - 54 + 27;
}
else if ((cw >> 4) <= 198)
{
tab = (cw >> 4) - 140 + 43;
}
else if ((cw >> 3) <= 452)
{
tab = (cw >> 3) - 398 + 102;
}
else if ((cw >> 2) <= 1000)
{
tab = (cw >> 2) - 906 + 157;
}
else if ((cw >> 1) <= 2044)
{
tab = (cw >> 1) - 2002 + 252;
}
else
{
tab = cw - 4090 + 295;
}
tab = *(huff_tab11 + tab);
pInputStream->usedBits -= (12 - (tab & MASK_LOW16));
return ((Int)(tab >> UPPER16));
}
Int decode_huff_scl(
BITS *pInputStream)
{
Int32 tab;
Int32 cw;
cw = getbits(
19,
pInputStream);
if ((cw >> 18) == 0)
{
pInputStream->usedBits -= (19 - 1); /* used 1 bits */
return 60; /* idx is 60 */
}
else if ((cw >> 13) <= 59)
{
tab = (cw >> 13) - 32;
}
else if ((cw >> 10) <= 505)
{
tab = (cw >> 10) - 480 + 28;
}
else if ((cw >> 7) <= 4089)
{
tab = (cw >> 7) - 4048 + 54;
}
else if ((cw >> 5) <= 16377)
{
tab = (cw >> 5) - 16360 + 96;
}
else if ((cw >> 3) <= 65526)
{
tab = (cw >> 3) - 65512 + 114;
}
else if ((cw >> 1) <= 262120)
{
tab = (cw >> 1) - 262108 + 129;
}
else
{
tab = cw - 524242 + 142;
}
tab = *(huff_tab_scl + tab);
pInputStream->usedBits -= (19 - (tab & MASK_LOW16));
return ((Int)(tab >> UPPER16));
}

View File

@@ -0,0 +1,163 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: decode_noise_floorlevels.c
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
------------------------------------------------------------------------------
REQUIREMENTS
------------------------------------------------------------------------------
REFERENCES
SC 29 Software Copyright Licencing Disclaimer:
This software module was originally developed by
Coding Technologies
and edited by
-
in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
standards for reference purposes and its performance may not have been
optimized. This software module is an implementation of one or more tools as
specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
ISO/IEC gives users free license to this software module or modifications
thereof for use in products claiming conformance to audiovisual and
image-coding related ITU Recommendations and/or ISO/IEC International
Standards. ISO/IEC gives users the same free license to this software module or
modifications thereof for research purposes and further ISO/IEC standardisation.
Those intending to use this software module in products are advised that its
use may infringe existing patents. ISO/IEC have no liability for use of this
software module or modifications thereof. Copyright is not released for
products that do not conform to audiovisual and image-coding related ITU
Recommendations and/or ISO/IEC International Standards.
The original developer retains full right to modify and use the code for its
own purpose, assign or donate the code to a third party and to inhibit third
parties from using the code for products that do not conform to audiovisual and
image-coding related ITU Recommendations and/or ISO/IEC International Standards.
This copyright notice must be included in all copies or derivative works.
Copyright (c) ISO/IEC 2002.
------------------------------------------------------------------------------
PSEUDO-CODE
------------------------------------------------------------------------------
*/
#ifdef AAC_PLUS
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "decode_noise_floorlevels.h"
#include "sbr_constants.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
void decode_noise_floorlevels(SBR_FRAME_DATA * hFrameData)
{
Int32 env;
Int32 i;
Int32 * frameInfo = hFrameData->frameInfo;
Int32 nNfb = hFrameData->nNfb;
Int32 * domain_vec = hFrameData->domain_vec2;
Int32 * sbrNoiseFloorLevel_man = hFrameData->sbrNoiseFloorLevel_man;
Int32 * prevNoiseLevel_man = hFrameData->prevNoiseLevel_man;
Int32 nEnv = frameInfo[(frameInfo[0] << 1) + 3];
for (env = 0; env < nEnv; env++)
{
if (domain_vec[env] == 0)
{
prevNoiseLevel_man[0] = *(sbrNoiseFloorLevel_man++);
for (i = 1; i < nNfb; i++)
{
*sbrNoiseFloorLevel_man += *(sbrNoiseFloorLevel_man - 1);
prevNoiseLevel_man[i] = *(sbrNoiseFloorLevel_man++);
}
}
else
{
for (i = 0; i < nNfb; i++)
{
*sbrNoiseFloorLevel_man += prevNoiseLevel_man[i];
prevNoiseLevel_man[i] = *(sbrNoiseFloorLevel_man++);
}
}
}
}
#endif

View File

@@ -0,0 +1,92 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: decode_noise_floorlevels.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef DECODENOISEFLOORLEVELS_H
#define DECODENOISEFLOORLEVELS_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "s_sbr_frame_data.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
{
#endif
void decode_noise_floorlevels(SBR_FRAME_DATA * hFrameData);
#ifdef __cplusplus
}
#endif
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,287 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./src/deinterleave.c
------------------------------------------------------------------------------
REVISION HISTORY
Description: Modified from original shareware code
Description: (1) Modified with new template, rename variables
(2) Removed for-loop to calculate win_inc, win_inc = SN2 (128)
(3) Replaced for-loop with memcpy
(4) Converted Int16 -> Int
Description: Modified per review comments
Who: Date:
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Inputs:
interleaved = input array that contains interleaved coefficients
Data Type Int
deinterleaved = output array that will be updated with de-interleaved
coefficients of input array. Data Type Int
pFrameInfo = pointer to structure that holds information of current
frame. Data Type FrameInfo
Local Stores/Buffers/Pointers Needed:
None
Global Stores/Buffers/Pointers Needed:
None
Outputs:
None
Pointers and Buffers Modified:
deinterleaved contents updated with de-interleaved coefficients from
the input array: interleaved
Local Stores Modified:
None
Global Stores Modified:
None
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
This function performs the deinterleaving across all short windows in
each group
------------------------------------------------------------------------------
REQUIREMENTS
This function should replace the contents of pDeinterleaved with the
de-interleaved 1024 coefficients of one frame
------------------------------------------------------------------------------
REFERENCES
(1) MPEG-2 NBC Audio Decoder
"This software module was originally developed by AT&T, Dolby
Laboratories, Fraunhofer Gesellschaft IIS in the course of development
of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
3. This software module is an implementation of a part of one or more
MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
standards free license to this software module or modifications thereof
for use in hardware or software products claiming conformance to the
MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
module in hardware or software products are advised that this use may
infringe existing patents. The original developer of this software
module and his/her company, the subsequent editors and their companies,
and ISO/IEC have no liability for use of this software module or
modifications thereof in an implementation. Copyright is not released
for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
developer retains full right to use the code for his/her own purpose,
assign or donate the code to a third party and to inhibit third party
from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
This copyright notice must be included in all copies or derivative
works."
Copyright(c)1996.
(2) ISO/IEC 14496-3: 1999(E)
Subpart 4 p78 quant_to_spec
------------------------------------------------------------------------------
PSEUDO-CODE
pInterleaved = interleaved;
pDeinterleaved = deinterleaved;
pSfbPerWin = pFrameInfo->sfb_per_win;
ngroups = pFrameInfo->num_groups;
pGroupLen = pFrameInfo->group_len;
pGroup = pDeinterleaved;
FOR (group = ngroups; group > 0; group--)
pSfbWidth = pFrameInfo->sfb_width_128;
sfb_inc = 0;
pStart = pInterleaved;
FOR (sfb = pSfbPerWin[ngroups-group]; sfb > 0; sfb--)
pWin = pGroup;
FOR (win = pGroupLen[ngroups-group]; win > 0; win--)
pDeinterleaved = pWin + sfb_inc;
pv_memcpy(
pDeinterleaved,
pInterleaved,
*pSfbWidth*sizeof(*pInterleaved));
pInterleaved += *pSfbWidth;
pWin += SN2;
ENDFOR (win)
sfb_inc += *pSfbWidth++;
ENDFOR (sfb)
pGroup += (pInterleaved - pStart);
ENDFOR (group)
------------------------------------------------------------------------------
RESOURCES USED
When the code is written for a specific target processor the
the resources used should be documented below.
STACK USAGE: [stack count for this module] + [variable to represent
stack usage for each subroutine called]
where: [stack usage variable] = stack usage for [subroutine
name] (see [filename].ext)
DATA MEMORY USED: x words
PROGRAM MEMORY USED: x words
CLOCK CYCLES: [cycle count equation for this module] + [variable
used to represent cycle count for each subroutine
called]
where: [cycle count variable] = cycle count for [subroutine
name] (see [filename].ext)
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "huffman.h"
#include "aac_mem_funcs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
void deinterleave(
Int16 interleaved[],
Int16 deinterleaved[],
FrameInfo *pFrameInfo)
{
Int group; /* group index */
Int sfb; /* scalefactor band index */
Int win; /* window index */
Int16 *pGroup;
Int16 *pWin;
Int16 *pStart;
Int16 *pInterleaved;
Int16 *pDeinterleaved;
Int sfb_inc;
Int ngroups;
Int *pGroupLen;
Int *pSfbPerWin;
Int *pSfbWidth;
pInterleaved = interleaved;
pDeinterleaved = deinterleaved;
pSfbPerWin = pFrameInfo->sfb_per_win;
ngroups = pFrameInfo->num_groups;
pGroupLen = pFrameInfo->group_len;
pGroup = pDeinterleaved;
for (group = ngroups; group > 0; group--)
{
pSfbWidth = pFrameInfo->sfb_width_128;
sfb_inc = 0;
pStart = pInterleaved;
/* Perform the deinterleaving across all windows in a group */
for (sfb = pSfbPerWin[ngroups-group]; sfb > 0; sfb--)
{
pWin = pGroup;
for (win = pGroupLen[ngroups-group]; win > 0; win--)
{
pDeinterleaved = pWin + sfb_inc;
pv_memcpy(
pDeinterleaved,
pInterleaved,
*pSfbWidth*sizeof(*pInterleaved));
pInterleaved += *pSfbWidth;
pWin += SN2;
} /* for (win) */
sfb_inc += *pSfbWidth++;
} /* for (sfb) */
pGroup += (pInterleaved - pStart);
} /* for (group) */
} /* deinterleave */

View File

@@ -0,0 +1,279 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./src/digit_reversal_tables.c
Funtions:
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
MODULE DESCRIPTION
Tables for digit reverse operation
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "digit_reversal_tables.h"
#include "imdct_fxp.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL VARIABLE DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*
------------------------------------------------------------------------------
Digit Reverse tables
------------------------------------------------------------------------------
*/
const Int16 digit_reverse_64[ 64] =
{
+ 0, + 32, + 64, + 96,
+ 8, + 40, + 72, + 104,
+ 16, + 48, + 80, + 112,
+ 24, + 56, + 88, + 120,
+ 2, + 34, + 66, + 98,
+ 10, + 42, + 74, + 106,
+ 18, + 50, + 82, + 114,
+ 26, + 58, + 90, + 122,
+ 4, + 36, + 68, + 100,
+ 12, + 44, + 76, + 108,
+ 20, + 52, + 84, + 116,
+ 28, + 60, + 92, + 124,
+ 6, + 38, + 70, + 102,
+ 14, + 46, + 78, + 110,
+ 22, + 54, + 86, + 118,
+ 30, + 62, + 94, + 126
};
const Int16 digit_reverse_256[ 256] =
{
+ 0, + 128, + 256, + 384,
+ 32, + 160, + 288, + 416,
+ 64, + 192, + 320, + 448,
+ 96, + 224, + 352, + 480,
+ 8, + 136, + 264, + 392,
+ 40, + 168, + 296, + 424,
+ 72, + 200, + 328, + 456,
+ 104, + 232, + 360, + 488,
+ 16, + 144, + 272, + 400,
+ 48, + 176, + 304, + 432,
+ 80, + 208, + 336, + 464,
+ 112, + 240, + 368, + 496,
+ 24, + 152, + 280, + 408,
+ 56, + 184, + 312, + 440,
+ 88, + 216, + 344, + 472,
+ 120, + 248, + 376, + 504,
+ 2, + 130, + 258, + 386,
+ 34, + 162, + 290, + 418,
+ 66, + 194, + 322, + 450,
+ 98, + 226, + 354, + 482,
+ 10, + 138, + 266, + 394,
+ 42, + 170, + 298, + 426,
+ 74, + 202, + 330, + 458,
+ 106, + 234, + 362, + 490,
+ 18, + 146, + 274, + 402,
+ 50, + 178, + 306, + 434,
+ 82, + 210, + 338, + 466,
+ 114, + 242, + 370, + 498,
+ 26, + 154, + 282, + 410,
+ 58, + 186, + 314, + 442,
+ 90, + 218, + 346, + 474,
+ 122, + 250, + 378, + 506,
+ 4, + 132, + 260, + 388,
+ 36, + 164, + 292, + 420,
+ 68, + 196, + 324, + 452,
+ 100, + 228, + 356, + 484,
+ 12, + 140, + 268, + 396,
+ 44, + 172, + 300, + 428,
+ 76, + 204, + 332, + 460,
+ 108, + 236, + 364, + 492,
+ 20, + 148, + 276, + 404,
+ 52, + 180, + 308, + 436,
+ 84, + 212, + 340, + 468,
+ 116, + 244, + 372, + 500,
+ 28, + 156, + 284, + 412,
+ 60, + 188, + 316, + 444,
+ 92, + 220, + 348, + 476,
+ 124, + 252, + 380, + 508,
+ 6, + 134, + 262, + 390,
+ 38, + 166, + 294, + 422,
+ 70, + 198, + 326, + 454,
+ 102, + 230, + 358, + 486,
+ 14, + 142, + 270, + 398,
+ 46, + 174, + 302, + 430,
+ 78, + 206, + 334, + 462,
+ 110, + 238, + 366, + 494,
+ 22, + 150, + 278, + 406,
+ 54, + 182, + 310, + 438,
+ 86, + 214, + 342, + 470,
+ 118, + 246, + 374, + 502,
+ 30, + 158, + 286, + 414,
+ 62, + 190, + 318, + 446,
+ 94, + 222, + 350, + 478,
+ 126, + 254, + 382, + 510
};
const Int16 digit_reverse_swap_256[ 241] =
{
+ 2, + 128, + 4, + 256,
+ 6, + 384, + 8, + 32,
+ 10, + 160, + 12, + 288,
+ 14, + 416, + 16, + 64,
+ 18, + 192, + 20, + 320,
+ 22, + 448, + 24, + 96,
+ 26, + 224, + 28, + 352,
+ 30, + 480, + 34, + 136,
+ 36, + 264, + 38, + 392,
+ 42, + 168, + 44, + 296,
+ 46, + 424, + 48, + 72,
+ 50, + 200, + 52, + 328,
+ 54, + 456, + 56, + 104,
+ 58, + 232, + 60, + 360,
+ 62, + 488, + 66, + 144,
+ 68, + 272, + 70, + 400,
+ 74, + 176, + 76, + 304,
+ 78, + 432, + 82, + 208,
+ 84, + 336, + 86, + 464,
+ 88, + 112, + 90, + 240,
+ 92, + 368, + 94, + 496,
+ 98, + 152, + 100, + 280,
+ 102, + 408, + 106, + 184,
+ 108, + 312, + 110, + 440,
+ 114, + 216, + 116, + 344,
+ 118, + 472, + 122, + 248,
+ 124, + 376, + 126, + 504,
+ 132, + 258, + 134, + 386,
+ 138, + 162, + 140, + 290,
+ 142, + 418, + 146, + 194,
+ 148, + 322, + 150, + 450,
+ 154, + 226, + 156, + 354,
+ 158, + 482, + 164, + 266,
+ 166, + 394, + 172, + 298,
+ 174, + 426, + 178, + 202,
+ 180, + 330, + 182, + 458,
+ 186, + 234, + 188, + 362,
+ 190, + 490, + 196, + 274,
+ 198, + 402, + 204, + 306,
+ 206, + 434, + 212, + 338,
+ 214, + 466, + 218, + 242,
+ 220, + 370, + 222, + 498,
+ 228, + 282, + 230, + 410,
+ 236, + 314, + 238, + 442,
+ 244, + 346, + 246, + 474,
+ 252, + 378, + 254, + 506,
+ 262, + 388, + 268, + 292,
+ 270, + 420, + 276, + 324,
+ 278, + 452, + 284, + 356,
+ 286, + 484, + 294, + 396,
+ 302, + 428, + 308, + 332,
+ 310, + 460, + 316, + 364,
+ 318, + 492, + 326, + 404,
+ 334, + 436, + 342, + 468,
+ 348, + 372, + 350, + 500,
+ 358, + 412, + 366, + 444,
+ 374, + 476, + 382, + 508,
+ 398, + 422, + 406, + 454,
+ 414, + 486, + 438, + 462,
+ 446, + 494, + 478, + 502
};
#ifdef __cplusplus
extern "C"
{
#endif
void digit_reversal_swapping(Int32 *y, Int32 *x);
#ifdef __cplusplus
}
#endif
void digit_reversal_swapping(Int32 *y, Int32 *x)
{
Int16 i, j;
Int32 tmp[2];
const Int16 *pTable;
pTable = digit_reverse_swap_256;
for (Int k = 120; k != 0; k--)
{
i = *pTable++;
j = *pTable++;
tmp[0] = y[i];
tmp[1] = y[i+1];
y[i] = y[j];
y[i+1] = y[j+1];
y[j] = tmp[0];
y[j+1] = tmp[1];
tmp[0] = x[j];
tmp[1] = x[j+1];
x[j] = x[i];
x[j+1] = x[i+1];
x[i] = tmp[0];
x[i+1] = tmp[1];
}
}

View File

@@ -0,0 +1,86 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./include/DIGIT_REVERSAL_TABLES.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
Header file for functions digit_reversal_tables
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef DIGIT_REVERSAL_TABLES_H
#define DIGIT_REVERSAL_TABLES_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
extern const Int16 digit_reverse_64[];
extern const Int16 digit_reverse_256[];
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif /* DIGIT_REVERSAL_TABLES_H */

View File

@@ -0,0 +1,172 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: dst16.c
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Int32 x 32-bit integer input length 16
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
Implement discrete sine transform of lenght 16
------------------------------------------------------------------------------
REQUIREMENTS
------------------------------------------------------------------------------
REFERENCES
------------------------------------------------------------------------------
PSEUDO-CODE
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#ifdef AAC_PLUS
#include "dst16.h"
#include "dst8.h"
#include "fxp_mul32.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
#define R_SHIFT 28
#define Qfmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
const Int32 CosTable_8[8] =
{
Qfmt(0.50241928618816F), Qfmt(0.52249861493969F),
Qfmt(0.56694403481636F), Qfmt(0.64682178335999F),
Qfmt(0.78815462345125F), Qfmt(1.06067768599035F),
Qfmt(1.72244709823833F), Qfmt(5.10114861868916F)
};
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
void dst_16(Int32 vec[], Int32 scratch_mem[]) /* scratch_mem size 8 */
{
Int32 *temp_even = scratch_mem;
Int i;
const Int32 *pt_cos = &CosTable_8[7];
Int32 tmp0 = vec[15] >> 1;
Int32 tmp1, tmp2;
Int32 *pt_even = temp_even;
Int32 *pt_odd = vec;
Int32 *pt_vec = vec;
Int32 *pt_vecN_1;
Int32 tmp3;
*(pt_even++) = *(pt_vec++);
tmp1 = *(pt_vec++);
*(pt_odd++) = tmp1;
for (i = 3; i != 0; i--)
{
*(pt_even++) = *(pt_vec++);
tmp2 = *(pt_vec++);
*(pt_even++) = *(pt_vec++);
tmp3 = *(pt_vec++);
*(pt_odd++) = tmp2 + tmp1;
*(pt_odd++) = tmp3 + tmp2;
tmp1 = tmp3;
}
*(pt_even) = *(pt_vec++);
*(pt_odd++) = *(pt_vec) + tmp1;
dst_8(temp_even);
dst_8(vec);
pt_vec = &vec[7];
pt_even = &temp_even[7];
pt_vecN_1 = &vec[8];
tmp1 = *(pt_even--);
for (i = 4; i != 0; i--)
{
tmp3 = fxp_mul32_Q28((*(pt_vec) - tmp0), *(pt_cos--));
tmp2 = *(pt_even--);
*(pt_vec--) = tmp3 + tmp1;
*(pt_vecN_1++) = tmp3 - tmp1;
tmp3 = fxp_mul32_Q28((*(pt_vec) + tmp0), *(pt_cos--));
tmp1 = *(pt_even--);
*(pt_vecN_1++) = tmp3 - tmp2;
*(pt_vec--) = tmp3 + tmp2;
}
}
#endif

View File

@@ -0,0 +1,68 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./c/include/dst16.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
------------------------------------------------------------------------------
*/
#ifndef DST16_H
#define DST16_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#ifdef __cplusplus
extern "C"
{
#endif
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES AND SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
void dst_16(Int32 vec[], Int32 scratch_mem[]);
#ifdef __cplusplus
}
#endif
#endif /* DST16_H */

View File

@@ -0,0 +1,200 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: dst32.c
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Int32 x 32-bit integer input length 32
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
Implement discrete sine transform of lenght 32
------------------------------------------------------------------------------
REQUIREMENTS
------------------------------------------------------------------------------
REFERENCES
------------------------------------------------------------------------------
PSEUDO-CODE
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#ifdef AAC_PLUS
#include "dst32.h"
#include "dst16.h"
#include "fxp_mul32.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
#define R_SHIFT1 29
#define Qfmt29(x) (Int32)(x*((Int32)1<<R_SHIFT1) + (x>=0?0.5F:-0.5F))
#define Qfmt31(a) (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F))
const Int32 CosTable_16[14] =
{
Qfmt31(0.50060299823520F), Qfmt31(0.50547095989754F),
Qfmt31(0.51544730992262F), Qfmt31(0.53104259108978F),
Qfmt31(0.55310389603444F), Qfmt31(0.58293496820613F),
Qfmt31(0.62250412303566F), Qfmt31(0.67480834145501F),
Qfmt31(0.74453627100230F), Qfmt31(0.83934964541553F),
Qfmt29(0.97256823786196F), Qfmt29(1.16943993343288F),
Qfmt29(1.48416461631417F), Qfmt29(2.05778100995341F)
};
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
void dst_32(Int32 vec[], Int32 scratch_mem[]) /* scratch_mem size 32 */
{
Int32 *temp_even = scratch_mem;
Int32 i;
const Int32 *pt_cos = &CosTable_16[13];
Int32 tmp0 = vec[31] >> 1;
Int32 tmp1, tmp2;
Int32 *pt_even = temp_even;
Int32 *pt_odd = vec;
Int32 *pt_vec = vec;
Int32 *pt_vecN_1 = vec;
Int32 tmp3;
tmp1 = 0;
for (i = 5; i != 0; i--)
{
*(pt_even++) = *(pt_vec++);
tmp2 = *(pt_vec++);
*(pt_even++) = *(pt_vec++);
tmp3 = *(pt_vec++);
*(pt_even++) = *(pt_vec++);
*(pt_odd++) = tmp2 + tmp1;
*(pt_odd++) = tmp3 + tmp2;
tmp1 = *(pt_vec++);
*(pt_odd++) = tmp1 + tmp3;
}
*(pt_even) = *(pt_vec++);
*(pt_odd) = *(pt_vec) + tmp1;
dst_16(temp_even, &scratch_mem[16]);
dst_16(vec, &scratch_mem[24]);
pt_vecN_1 = &vec[16];
tmp1 = temp_even[15];
tmp3 = fxp_mul32_Q31((vec[15] - tmp0) << 3, Qfmt31(0.63687550772175F)) << 2;
tmp2 = temp_even[14];
*(pt_vecN_1++) = tmp3 - tmp1;
vec[15] = tmp3 + tmp1;
tmp1 = temp_even[13];
tmp3 = fxp_mul32_Q31((vec[14] + tmp0) << 3, Qfmt31(0.85190210461718F));
*(pt_vecN_1++) = tmp3 - tmp2;
vec[14] = tmp3 + tmp2;
pt_even = &temp_even[12];
pt_vec = &vec[13];
for (i = 2; i != 0; i--)
{
tmp3 = fxp_mul32_Q29((*(pt_vec) - tmp0), *(pt_cos--));
tmp2 = *(pt_even--);
*(pt_vec--) = tmp3 + tmp1;
*(pt_vecN_1++) = tmp3 - tmp1;
tmp3 = fxp_mul32_Q29((*(pt_vec) + tmp0), *(pt_cos--));
tmp1 = *(pt_even--);
*(pt_vec--) = tmp3 + tmp2;
*(pt_vecN_1++) = tmp3 - tmp2;
}
for (i = 5; i != 0; i--)
{
tmp3 = fxp_mul32_Q31((*(pt_vec) - tmp0) << 1, *(pt_cos--));
tmp2 = *(pt_even--);
*(pt_vec--) = tmp3 + tmp1;
*(pt_vecN_1++) = tmp3 - tmp1;
tmp3 = fxp_mul32_Q31((*(pt_vec) + tmp0) << 1, *(pt_cos--));
tmp1 = *(pt_even--);
*(pt_vec--) = tmp3 + tmp2;
*(pt_vecN_1++) = tmp3 - tmp2;
}
}
#endif

View File

@@ -0,0 +1,69 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./c/include/dst32.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
------------------------------------------------------------------------------
*/
#ifndef DST32_H
#define DST32_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
{
#endif
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
----------------------------------------------------------------------------*/
extern const Int32 CosTable_16[];
/*----------------------------------------------------------------------------
; DEFINES AND SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
void dst_32(Int32 vec[], Int32 scratch_mem[]);
#ifdef __cplusplus
}
#endif
#endif /* DST32_H */

View File

@@ -0,0 +1,179 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: dst8.c
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Int32 x 32-bit integer input length 8
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
Implement discrete sine transform of lenght 8
------------------------------------------------------------------------------
REQUIREMENTS
------------------------------------------------------------------------------
REFERENCES
------------------------------------------------------------------------------
PSEUDO-CODE
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#ifdef AAC_PLUS
#include "dst8.h"
#include "fxp_mul32.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
#define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F))
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
#define R_SHIFT 29
#define Qfmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
#define Qfmt31(x) (Int32)(x*0x7FFFFFFF + (x>=0?0.5F:-0.5F))
void dst_8(Int32 vec[])
{
Int32 temp1;
Int32 temp2;
Int32 temp3;
Int32 temp4;
Int32 temp5;
Int32 temp6;
Int32 temp7;
Int32 tmp_a;
Int32 tmp_aa;
Int32 tmp_b;
Int32 tmp_bb;
Int32 tmp_c;
Int32 tmp_cc;
Int32 tmp_d;
Int32 tmp_dd;
temp1 = fxp_mul32_by_16(vec[1], Qfmt15(0.50979557910416F)); /* (1/(2*cos( phi)));*/
temp2 = fxp_mul32_by_16(vec[2], Qfmt15(0.54119610014620F)); /* (1/(2*cos(2*phi)));*/
temp3 = fxp_mul32_by_16(vec[3], Qfmt15(0.60134488693505F)); /* (1/(2*cos(3*phi)));*/
temp5 = fxp_mul32_by_16(vec[5], Qfmt15(0.89997622313642F)); /* (1/(2*cos(5*phi)));*/
temp6 = fxp_mul32_by_16(vec[6] << 1, Qfmt15(0.65328148243819F)); /* (1/(2*cos(6*phi)));*/
temp7 = vec[7] + fxp_mul32_Q31(vec[7], Qfmt31(0.56291544774152F)); /* (1/(2*cos(7*phi)));*/
/* even */
tmp_a = fxp_mul32_Q31((temp2 + temp6) << 1, Qfmt31(0.70710678118655F));
tmp_b = (temp2 - temp6) + tmp_a;
temp4 = fxp_mul32_by_16(vec[4], Qfmt15(0.70710678118655F));
vec[0] = tmp_a + temp4;
vec[1] = tmp_b + temp4;
vec[2] = tmp_b - temp4;
vec[3] = tmp_a - temp4;
/* odd */
tmp_a = fxp_mul32_by_16((temp1 + temp7) << 1, Qfmt15(0.54119610014620F)); /* (1/(2*cos(2*phi))); */
tmp_aa = (temp1 - temp7);
tmp_bb = (temp5 - temp3);
temp5 = fxp_mul32_Q29((temp5 + temp3), Qfmt(1.30656296487638F)); /* (1/(2*cos(6*phi))); */
tmp_c = fxp_mul32_by_16((tmp_a + temp5) << 1, Qfmt15(0.70710678118655F));
tmp_cc = tmp_a - temp5;
tmp_d = fxp_mac32_by_16((tmp_aa - tmp_bb) << 1, Qfmt15(0.70710678118655F), tmp_c);
tmp_dd = (tmp_aa + tmp_bb);
tmp_dd += tmp_c;
tmp_a = tmp_d + tmp_cc;
vec[5] = tmp_a - vec[2];
vec[2] += tmp_a;
temp5 = tmp_dd + tmp_cc;
vec[4] = temp5 - vec[3];
vec[3] += temp5;
vec[7] = tmp_c - vec[0];
vec[0] += tmp_c;
vec[6] = tmp_d - vec[1];
vec[1] += tmp_d;
}
#endif

View File

@@ -0,0 +1,68 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./c/include/dst8.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
------------------------------------------------------------------------------
*/
#ifndef DST8_H
#define DST8_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
{
#endif
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES AND SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
void dst_8(Int32 vec[]);
#ifdef __cplusplus
}
#endif
#endif /* DST8_H */

View File

@@ -0,0 +1,97 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./include/e_ADIF_Const.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
enum for ADIF header related constants
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef E_ADIF_CONST_H
#define E_ADIF_CONST_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
typedef enum
{
/*
* audio data interchange format header
*/
LEN_ADIF_ID = (32 / 8),
LEN_COPYRT_PRES = 1,
LEN_COPYRT_ID = (72 / 8),
LEN_ORIG = 1,
LEN_HOME = 1,
LEN_BS_TYPE = 1,
LEN_BIT_RATE = 23,
LEN_NUM_PCE = 4,
LEN_ADIF_BF = 20
} eADIF_Const;
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -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.
* -------------------------------------------------------------------
*/
/*
Pathname: ./include/e_BlockSwitching.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
enum for BlockSwitching related constants
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef E_BLOCK_SWITCHING_H
#define E_BLOCK_SWITCHING_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
typedef enum
{
/*
* block switching
*/
LN = 2048,
SN = 256,
LN2 = LN / 2,
SN2 = SN / 2,
LN4 = LN / 4,
SN4 = SN / 4,
NSHORT = LN / SN,
MAX_SBK = NSHORT,
MAX_WIN = MAX_SBK,
ONLY_LONG_WINDOW = 0,
LONG_START_WINDOW,
EIGHT_SHORT_WINDOW,
LONG_STOP_WINDOW,
NUM_WIN_SEQ,
WLONG = ONLY_LONG_WINDOW,
WSTART,
WSHORT,
WSTOP,
MAXBANDS = 16 * NSHORT, /* max number of scale factor bands */
MAXFAC = 121, /* maximum scale factor */
MIDFAC = (MAXFAC - 1) / 2,
SF_OFFSET = 100 /* global gain must be positive */
} eBlockSwitching;
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,88 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: e_coupling_mode.h
Funtions:
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef E_COUPLING_MODE_H
#define E_COUPLING_MODE_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
typedef enum
{
COUPLING_OFF,
COUPLING_LEVEL,
COUPLING_BAL
}
COUPLING_MODE;
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,99 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./include/e_BLOCKTYPE.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
enum for BlockType related constants
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef E_ELEMENTID_H
#define E_ELEMENTID_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
typedef enum
{
/* sfb 40, coef 672, pred bw of 15.75 kHz at 48 kHz
* this is also the highest number of bins used
* by predictor for any sampling rate
*/
MAX_PRED_SFB = 40, /* 48 kHz only, now obsolete */
MAX_PRED_BINS = 672,
ID_SCE = 0,
ID_CPE,
ID_CCE,
ID_LFE,
ID_DSE,
ID_PCE,
ID_FIL,
ID_END
}
ElementId;
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,119 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./include/e_HuffmanConst.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
enum for Huffman related constants
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef E_HUFFMAN_CONST_H
#define E_HUFFMAN_CONST_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
typedef enum
{
/*
* specify huffman tables as signed (1) or unsigned (0)
*/
HUF1SGN = 1,
HUF2SGN = 1,
HUF3SGN = 0,
HUF4SGN = 0,
HUF5SGN = 1,
HUF6SGN = 1,
HUF7SGN = 0,
HUF8SGN = 0,
HUF9SGN = 0,
HUF10SGN = 0,
HUF11SGN = 0,
ZERO_HCB = 0,
BY4BOOKS = 4,
ESCBOOK = 11,
NSPECBOOKS = ESCBOOK + 1,
BOOKSCL = NSPECBOOKS,
NBOOKS = NSPECBOOKS + 1,
INTENSITY_HCB2 = 14,
INTENSITY_HCB = 15,
NOISE_HCB = 13,
NOISE_HCB2 = 113,
NOISE_PCM_BITS = 9,
NOISE_PCM_OFFSET = (1 << (NOISE_PCM_BITS - 1)),
NOISE_OFFSET = 90,
LONG_SECT_BITS = 5,
SHORT_SECT_BITS = 3
} eHuffmanConst;
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,96 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./include/e_infoinitConst.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
enum for Infoinit related constants
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef E_INFOINIT_CONST_H
#define E_INFOINIT_CONST_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "chans.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
typedef enum
{
/* block switch windows for single channels or channel pairs */
Winds = Chans,
/* average channel block length, bytes */
Avjframe = 341,
TEXP = 128, /* size of exp cache table */
MAX_IQ_TBL = 128, /* size of inv quant table */
MAXFFT = LN4
} infoinitConst;
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,91 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: e_invf_mode.h
Funtions:
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef E_INVF_MODE_H
#define E_INVF_MODE_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
typedef enum
{
INVF_OFF,
INVF_LOW_LEVEL,
INVF_MID_LEVEL,
INVF_HIGH_LEVEL,
INVF_NO_OVERRIDE
}
INVF_MODE;
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,91 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./include/e_MaskStatus.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
This file gives the enum of mask_present value used in getmask.c
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef E_MASKSTATUS_H
#define E_MASKSTATUS_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
enum
{
MASK_NOT_PRESENT,
MASK_FROM_BITSTREAM,
MASK_ALL_FRAME,
MASK_ERROR
};
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -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.
* -------------------------------------------------------------------
*/
/*
Pathname: e_MP4FF_const.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
This file enums the constants used by MP4FF header
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef E_MP4FF_CONST_H
#define E_MP4FF_CONST_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
typedef enum
{
LEN_OBJ_TYPE = 5,
LEN_SAMP_RATE_IDX = 4,
LEN_SAMP_RATE = 24,
LEN_CHAN_CONFIG = 4,
LEN_SYNC_EXTENSION_TYPE = 11,
LEN_FRAME_LEN_FLAG = 1,
LEN_DEPEND_ON_CORE = 1,
LEN_CORE_DELAY = 14,
LEN_EXT_FLAG = 1,
LEN_EP_CONFIG = 2,
LEN_LAYER_NUM = 3,
LEN_SUB_FRAME = 5,
LEN_LAYER_LEN = 11,
LEN_SECT_RES_FLAG = 1,
LEN_SCF_RES_FLAG = 1,
LEN_SPEC_RES_FLAG = 1,
LEN_EXT_FLAG3 = 1
} eMP4FF_const;
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -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.
* -------------------------------------------------------------------
*/
/*
Pathname: e_ProgConfigConst.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
enum for ProgConfig related constants
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef E_PROG_CONFIG_CONST_H
#define E_PROG_CONFIG_CONST_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
typedef enum
{
/*
* Program Configuration
*/
Main_Profile = 0,
LC_Profile = 1,
Fs_48 = 3,
Fs_44 = 4,
Fs_32 = 5,
LEN_PROFILE = 2,
LEN_SAMP_IDX = 4,
LEN_NUM_ELE = 4,
LEN_NUM_LFE = 2,
LEN_NUM_DAT = 3,
LEN_NUM_CCE = 4,
LEN_MIX_PRES = 1,
LEN_MMIX_IDX = 2,
LEN_PSUR_ENAB = 1,
LEN_ELE_IS_CPE = 1,
LEN_IND_SW_CCE = 1,
LEN_COMMENT_BYTES = 8
} eProgConfigConst;
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,130 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: e_RawBitstreamConst.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
enum for the Raw Bitstream related constants
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef E_RAW_BITSTREAM_CONST_H
#define E_RAW_BITSTREAM_CONST_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
typedef enum
{
LEN_SE_ID = 3,
LEN_TAG = 4,
LEN_COM_WIN = 1,
LEN_ICS_RESERV = 1,
LEN_WIN_SEQ = 2,
LEN_WIN_SH = 1,
LEN_MAX_SFBL = 6,
LEN_MAX_SFBS = 4,
LEN_CB = 4,
LEN_SCL_PCM = 8,
LEN_PRED_PRES = 1,
LEN_PRED_RST = 1,
LEN_PRED_RSTGRP = 5,
LEN_PRED_ENAB = 1,
LEN_MASK_PRES = 2,
LEN_MASK = 1,
LEN_PULSE_PRES = 1,
LEN_TNS_PRES = 1,
LEN_GAIN_PRES = 1,
LEN_PULSE_NPULSE = 2,
LEN_PULSE_ST_SFB = 6,
LEN_PULSE_POFF = 5,
LEN_PULSE_PAMP = 4,
NUM_PULSE_LINES = 4,
PULSE_OFFSET_AMP = 4,
LEN_IND_CCE_FLG = 1,
LEN_NCC = 3,
LEN_IS_CPE = 1,
LEN_CC_LR = 1,
LEN_CC_DOM = 1,
LEN_CC_SGN = 1,
LEN_CCH_GES = 2,
LEN_CCH_CGP = 1,
LEN_D_ALIGN = 1,
LEN_D_CNT = 8,
LEN_D_ESC = 8,
LEN_F_CNT = 4,
LEN_F_ESC = 8,
LEN_BYTE = 8,
LEN_PAD_DATA = 8,
LEN_PC_COMM = 9
} eRawBitstreamConst;
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,87 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: e_sbr_element_id.h
Funtions:
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef E_SBR_ELEMENT_ID_H
#define E_SBR_ELEMENT_ID_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
typedef enum
{
SBR_ID_SCE = 0,
SBR_ID_CPE
}
SBR_ELEMENT_ID;
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -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.
* -------------------------------------------------------------------
*/
/*
Filename: e_sbr_error.h
Funtions:
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef E_SBR_ERROR_H
#define E_SBR_ERROR_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
#define HANDLE_ERROR_INFO Int32
#define noError 0
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
typedef enum
{
SBRDEC_OK = 0,
SBRDEC_NOSYNCH,
SBRDEC_ILLEGAL_PROGRAM,
SBRDEC_ILLEGAL_TAG,
SBRDEC_ILLEGAL_CHN_CONFIG,
SBRDEC_ILLEGAL_SECTION,
SBRDEC_ILLEGAL_SCFACTORS,
SBRDEC_ILLEGAL_PULSE_DATA,
SBRDEC_MAIN_PROFILE_NOT_IMPLEMENTED,
SBRDEC_GC_NOT_IMPLEMENTED,
SBRDEC_ILLEGAL_PLUS_ELE_ID,
SBRDEC_CREATE_ERROR,
SBRDEC_NOT_INITIALIZED,
SBRDEC_TOO_MANY_SBR_ENVELOPES,
SBRDEC_INVALID_BITSTREAM
}
SBR_ERROR;
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,88 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: e_sbr_header_status.h
Funtions:
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef E_SBR_HEADER_STATUS_H
#define E_SBR_HEADER_STATUS_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
typedef enum
{
HEADER_OK,
HEADER_RESET,
HEADER_NOT_INITIALIZED
}
SBR_HEADER_STATUS;
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,87 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: e_sbr_master_status.h
Funtions:
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef E_SBR_MASTER_STATUS_H
#define E_SBR_MASTER_STATUS_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
typedef enum
{
MASTER_OK,
MASTER_RESET
}
SBR_MASTER_STATUS;
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,88 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: e_sbr_sync_state.h
Funtions:
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef E_SBR_SYNC_STATE_H
#define E_SBR_SYNC_STATE_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
typedef enum
{
SBR_NOT_INITIALIZED,
UPSAMPLING,
SBR_ACTIVE
}
SBR_SYNC_STATE;
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,88 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: e_sr_mode.h
Funtions:
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef E_SR_MODE_H
#define E_SR_MODE_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
typedef enum
{
SINGLE_RATE = 1,
UP_BY_2
}
SR_MODE;
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -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.
* -------------------------------------------------------------------
*/
/*
Pathname: ./include/e_tMP4AudioObjectType.h
This file contains enumerated types for MP4 Audio Object Types, as defined
in ISO/IEC 14496-3, AMMENDMENT 1 Dated 2000-09-15
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef E_TMP4AUDIOOBJECTTYPE_H
#define E_TMP4AUDIOOBJECTTYPE_H
#ifdef __cplusplus
extern "C"
{
#endif
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
typedef enum eMP4AudioObjectType
{
MP4AUDIO_NULL = 0, /* */
MP4AUDIO_AAC_MAIN = 1, /* */
MP4AUDIO_AAC_LC = 2, /* LC = Low Complexity */
MP4AUDIO_AAC_SSR = 3, /* SSR = Scalable Sampling Rate */
MP4AUDIO_LTP = 4, /* LTP = Long Term Prediction */
MP4AUDIO_SBR = 5, /* SBR = Spectral Band Replication */
MP4AUDIO_AAC_SCALABLE = 6, /* scales both bitrate and sampling rate */
MP4AUDIO_TWINVQ = 7, /* low bit rate */
MP4AUDIO_CELP = 8,
MP4AUDIO_HVXC = 9,
/* 10 is reserved */
/* 11 is reserved */
MP4AUDIO_TTSI = 12,
/* 13-16 are synthesis and MIDI types */
MP4AUDIO_ER_AAC_LC = 17, /* */
/* 18 is reserved */
MP4AUDIO_ER_AAC_LTP = 19, /* */
MP4AUDIO_ER_AAC_SCALABLE = 20, /* */
MP4AUDIO_ER_TWINVQ = 21, /* */
MP4AUDIO_ER_BSAC = 22, /* */
MP4AUDIO_ER_AAC_LD = 23, /* */
MP4AUDIO_ER_CELP = 24, /* */
MP4AUDIO_ER_HVXC = 25, /* */
MP4AUDIO_ER_HILN = 26, /* */
MP4AUDIO_PARAMETRIC = 27, /* */
MP4AUDIO_PS = 29 /* Explicit Parametric Stereo */
} tMP4AudioObjectType;
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/* Should not be any function declarations in this file */
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#ifdef __cplusplus
}
#endif
#endif /* E_TMP4AUDIOOBJECTTYPE_H */

View File

@@ -0,0 +1,91 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./include/e_TNS_Const.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
enum for TNS related constants
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef E_TNS_CONST_H
#define E_TNS_CONST_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
typedef enum
{
TNS_MAX_BANDS = 49,
TNS_MAX_ORDER = 20,
TNS_MAX_WIN = 8,
TNS_MAX_FILT = 3,
Q_SPEC = 11,
Q_LPC = 19
} eTNS_Const;
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,90 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./include/e_WINDOW_SEQUENCE.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
enum for Window Sequence related constants
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef E_WINDOW_SEQUENCE_H
#define E_WINDOW_SEQUENCE_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
typedef enum
{
ONLY_LONG_SEQUENCE,
LONG_START_SEQUENCE,
EIGHT_SHORT_SEQUENCE,
LONG_STOP_SEQUENCE,
NUM_WINDOW_SEQUENCE,
ENSURE_WINDOW_SEQUENCE_INT_SIZE = 0x7FFFFF
}
WINDOW_SEQUENCE;
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,89 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: e_Window_shape.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
enum for Window Sequence related constants
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef E_WINDOW_SHAPE_H
#define E_WINDOW_SHAPE_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
typedef enum
{
SINE_WINDOW = 0,
KAISER_BESSEL_WINDOW,
NUM_WINDOW_SHAPES,
ENSURE_WINDOW_SHAPE_INT_SIZE = 0x7FFFFF
}
WINDOW_SHAPE;
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,789 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./src/esc_iquant_scaling.c
Funtions: esc_iquant_scaling
------------------------------------------------------------------------------
REVISION HISTORY
Description: Modified from esc_iquant_fxp.c code
Description: Eliminated unused variables to avoid warnings, changed header
Who: Date:
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Inputs:
quantSpec[] = array of quantized compressed spectral coefficients, of
data type Int and length sfbWidth.
sfbWidth = number of array elements in quantSpec and the output array
coef, data type Int.
coef[] = output array of uncompressed coefficients, stored in a
variable Q format, depending on the maximum value found
for the group, array of Int32, length sfbWdith to be
overwritten.
QFormat = the output Q format for the array coef[].
scale = scaling factor after separating power of 2 factor out from
0.25*(sfb_scale - 100), i.e., 0.25*sfb_scale.
maxInput = maximum absolute value of quantSpec.
Local Stores/Buffers/Pointers Needed: None.
Global Stores/Buffers/Pointers Needed:
inverseQuantTable = lookup table of const integer values to the one third
power stored in Q27 format, in file iquant_table.c, const
array of UInt32, of size 1025.
Outputs: None
Pointers and Buffers Modified:
coef[] contents are overwritten with the uncompressed values from
quantSpec[]
Local Stores Modified: None.
Global Stores Modified: None.
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
This function performs the inverse quantization of the spectral coeficients
read from huffman decoding. It takes each input array value to the four
thirds power, then scales it according to the scaling factor input argument
,and stores the result in the output array in a variable Q format
depending upon the maximum input value found.
------------------------------------------------------------------------------
REQUIREMENTS
This function shall not have static or global variables.
------------------------------------------------------------------------------
REFERENCES
(1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding
of moving pictures and associated audio information - Part 7: Advanced
Audio Coding (AAC)", Section 10.3, "Decoding process", page 43.
(2) MPEG-2 NBC Audio Decoder
"This software module was originally developed by AT&T, Dolby
Laboratories, Fraunhofer Gesellschaft IIS in the course of development
of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
3. This software module is an implementation of a part of one or more
MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
standards free license to this software module or modifications thereof
for use in hardware or software products claiming conformance to the
MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
module in hardware or software products are advised that this use may
infringe existing patents. The original developer of this software
module and his/her company, the subsequent editors and their companies,
and ISO/IEC have no liability for use of this software module or
modifications thereof in an implementation. Copyright is not released
for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
developer retains full right to use the code for his/her own purpose,
assign or donate the code to a third party and to inhibit third party
from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
This copyright notice must be included in all copies or derivative
works."
Copyright(c)1996.
------------------------------------------------------------------------------
PSEUDO-CODE
maxInput = 0;
FOR (i = sfbWidth - 1; i >= 0; i--)
x = quantSpec[i];
IF ( x >= 0)
absX = x;
ELSE
absX = -x;
ENDIF
coef[i] = absX;
IF (absX > maxInput)
maxInput = absX;
ENDIF
ENDFOR
IF (maxInput == 0)
*pQFormat = QTABLE;
ELSE
temp = inverseQuantTable[(maxInput >> ORDER) + 1];
temp += ((1 << (QTABLE))-1);
temp >>= (QTABLE-1);
temp *= maxInput;
binaryDigits = 0;
WHILE( temp != 0)
temp >>= 1;
binaryDigits++;
WEND
IF (binaryDigits < (SIGNED32BITS - QTABLE))
binaryDigits = SIGNED32BITS - QTABLE;
ENDIF
*pQFormat = SIGNED32BITS - binaryDigits;
shift = QTABLE - *pQFormat;
IF (maxInput < TABLESIZE)
FOR (i = sfbWidth - 1; i >= 0; i--)
x = quantSpec[i];
absX = coef[i];
tmp_coef = x * (inverseQuantTable[absX] >> shift);
b_low = (tmp_coef & 0xFFFF);
b_high = (tmp_coef >> 16);
mult_low = ( (UInt32) b_low * scale );
mult_high = ( (Int32) b_high * scale );
mult_low >>= 16;
coef[i] = (Int32) (mult_high + mult_low);
ENDFOR
ELSE
FOR (i = sfbWidth; i >= 0 ; i--)
x = quantSpec[i];
absX = coef[i];
IF (absX < TABLESIZE)
tmp_coef = x * (inverseQuantTable[absX] >> shift);
ELSE
index = absX >> ORDER;
w1 = inverseQuantTable[index];
approxOneThird = (w1 * FACTOR) >> shift;
x1 = index * SPACING;
w2 = inverseQuantTable[index+1];
deltaOneThird = (w2 - w1) * (absX - x1);
deltaOneThird >>= (shift + ORDER - 1);
tmp_coef = x * (approxOneThird + deltaOneThird);
ENDIF
b_low = (mult_high & 0xFFFF);
b_high = (mult_high >> 16);
mult_low = ( (UInt32) b_low * scale );
mult_high = ( (Int32) b_high * scale );
mult_low >>= 16;
coef[i] = (Int32) (mult_high + mult_low);
ENDFOR
ENDIF
ENDIF
RETURN
------------------------------------------------------------------------------
RESOURCES USED
When the code is written for a specific target processor the
the resources used should be documented below.
STACK USAGE: [stack count for this module] + [variable to represent
stack usage for each subroutine called]
where: [stack usage variable] = stack usage for [subroutine
name] (see [filename].ext)
DATA MEMORY USED: x words
PROGRAM MEMORY USED: x words
CLOCK CYCLES: [cycle count equation for this module] + [variable
used to represent cycle count for each subroutine
called]
where: [cycle count variable] = cycle count for [subroutine
name] (see [filename].ext)
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "iquant_table.h"
#include "esc_iquant_scaling.h"
#include "aac_mem_funcs.h" /* For pv_memset */
#include "fxp_mul32.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*
* Read further on what order is.
* Note: If ORDER is not a multiple of 3, FACTOR is not an integer.
* Note: Portions of this function assume ORDER is 3, and so does the table
* in iquant_table.c
*/
#define ORDER (3)
/*
* For input values > TABLESIZE, multiply by FACTOR to get x ^ (1/3)
* FACTOR = 2 ^ (ORDER/3)
*/
#define FACTOR (2)
/*
* This is one more than the range of expected inputs.
*/
#define INPUTRANGE (8192)
/*
* SPACING is 2 ^ ORDER, and is the spacing between points when in the
* interpolation range.
*/
#define SPACING (1<<ORDER)
/*
* The actual table size is one more than TABLESIZE, to allow for
* interpolation for numbers near 8191
*/
#define TABLESIZE (INPUTRANGE/SPACING)
/*
* Format the table is stored in.
*/
#define QTABLE (27)
/*
* Number of bits for data in a signed 32 bit integer.
*/
#define SIGNED32BITS (31)
/*
* Round up value for intermediate values obtained from the table
*/
#define ROUND_UP (( ((UInt32) 1) << (QTABLE) )-1)
#define MASK_LOW16 0xffff
#define UPPER16 16
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL VARIABLE DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*
* Processing in this function is performed in these steps:
*
* 1) Find the overall Q format for the entire group of inputs. This consists
* of:
* a) Finding the maximum input
* b) estimate the maximum output
* c) Using the table, get max ^ (4/3), taking into account the table is
* in q format.
* 2) For each array element, see if the value is directly inside the table.
* a) If yes, just multiply by table value by itself, then shift as
* appropriate.
* b) If no, get an approximation (described below) for x ^ (1/3) by linearly
* interpolating using lower values in the table, then multiply by a
* correction factor, then multiply by x (see below).
*
* It more accurate to interpolate x ^ (1/3) then x ^ (4/3), so that is stored
* in the lookup table. For values not in the table, interpolation is used:
*
* We want y = x ^ (4/3) = x * (x ^ (1/3))
*
* Let x = w * (2 ^ m) where m is a constant, = ORDER
*
* then x ^ (1/3) = w ^ (1/3) * (2 ^ (m/3))
*
* w is most likely not an integer, so an interpolation with floor(w) and
* ceil(w) can be performed to approximate w ^ (1/3) by getting values out of
* the table. Then to get x ^ (1/3), multiply by FACTOR. If m = 0, 3, 6,
* then FACTOR is a simple power of 2, so a shift can do the job.
*
* The actual code employs some more tricks to speed things up, and because
* the table is stored in Q format.
*
* Rather than saving the sign of each input, the unsigned value of
* abs(x) ^ (1/3) is multiplied by the signed input value.
*/
#if ( defined(_ARM) || defined(_ARM_V4))
/*
* Absolute value for 16 bit-numbers
*/
__inline Int32 abs2(Int32 x)
{
Int32 z;
/*
z = x - (x<0);
x = z ^ sign(z)
*/
__asm
{
sub z, x, x, lsr #31
eor x, z, z, asr #31
}
return (x);
}
#define pv_abs(x) abs2(x)
#elif (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4))
/*
* Absolute value for 16 bit-numbers
*/
__inline Int32 abs2(Int32 x)
{
register Int32 z;
register Int32 y;
register Int32 ra = x;
asm volatile(
"sub %0, %2, %2, lsr #31\n\t"
"eor %1, %0, %0, asr #31"
: "=&r*i"(z),
"=&r*i"(y)
: "r"(ra));
return (y);
}
#define pv_abs(x) abs2(x)
#else
#define pv_abs(x) ((x) > 0)? (x) : (-x)
#endif
void esc_iquant_scaling(
const Int16 quantSpec[],
Int32 coef[],
const Int sfbWidth,
Int const QFormat,
UInt16 scale,
Int maxInput)
{
Int i;
Int x;
Int y;
Int index;
Int shift;
UInt absX;
UInt32 w1, w2;
UInt32 deltaOneThird;
UInt32 x1;
UInt32 approxOneThird;
Int32 mult_high;
#if ( defined(_ARM) || defined(_ARM_V4))
{
Int32 *temp;
Int32 R12, R11, R10, R9;
deltaOneThird = sizeof(Int32) * sfbWidth;
temp = coef;
// from standard library call for __rt_memset
__asm
{
MOV R12, #0x0
MOV R11, #0x0
MOV R10, #0x0
MOV R9, #0x0
SUBS deltaOneThird, deltaOneThird, #0x20
loop:
STMCSIA temp!, {R12, R11, R10, R9}
STMCSIA temp!, {R12, R11, R10, R9}
SUBCSS deltaOneThird, deltaOneThird, #0x20
BCS loop
MOVS deltaOneThird, deltaOneThird, LSL #28
STMCSIA temp!, {R12, R11, R10, R9}
STMMIIA temp!, {R12, R11}
}
}
#else
pv_memset(coef, 0, sizeof(Int32) * sfbWidth);
#endif
if (maxInput > 0)
{
shift = QTABLE - QFormat;
if (scale != 0)
{
if (maxInput < TABLESIZE)
{
for (i = sfbWidth - 1; i >= 0; i -= 4)
{
x = quantSpec[i];
y = quantSpec[i-1];
if (x)
{
absX = pv_abs(x);
mult_high = (x * (inverseQuantTable[absX] >> shift));
coef[i] = fxp_mul32_by_16(mult_high, scale) << 1;
}
if (y)
{
absX = pv_abs(y);
mult_high = y * (inverseQuantTable[absX] >> shift);
coef[i-1] = fxp_mul32_by_16(mult_high, scale) << 1;
}
x = quantSpec[i-2];
y = quantSpec[i-3];
if (x)
{
absX = pv_abs(x);
mult_high = x * (inverseQuantTable[absX] >> shift);
coef[i-2] = fxp_mul32_by_16(mult_high, scale) << 1;
}
if (y)
{
absX = pv_abs(y);
mult_high = y * (inverseQuantTable[absX] >> shift);
coef[i-3] = fxp_mul32_by_16(mult_high, scale) << 1;
}
} /* end for (i = sfbWidth - 1; i >= 0; i--) */
} /* end if (maxInput < TABLESIZE)*/
else /* maxInput >= TABLESIZE) */
{
for (i = sfbWidth - 1; i >= 0; i -= 4)
{
x = quantSpec[i];
if (x)
{
absX = pv_abs(x);
if (absX < TABLESIZE)
{
mult_high = x * (inverseQuantTable[absX] >> shift);
coef[i] = fxp_mul32_by_16(mult_high, scale) << 1;
}
else
{
index = absX >> ORDER;
w1 = inverseQuantTable[index];
w2 = inverseQuantTable[index+1];
approxOneThird = (w1 * FACTOR) >> shift;
x1 = index << ORDER;
deltaOneThird = (w2 - w1) * (absX - x1);
deltaOneThird >>= (shift + 2);
mult_high = x * (approxOneThird + deltaOneThird);
coef[i] = fxp_mul32_by_16(mult_high, scale) << 1;
}
} /* if(x) */
x = quantSpec[i-1];
if (x)
{
absX = pv_abs(x);
if (absX < TABLESIZE)
{
mult_high = (x * (inverseQuantTable[absX] >> shift));
coef[i-1] = fxp_mul32_by_16(mult_high, scale) << 1;
}
else
{
index = absX >> ORDER;
w1 = inverseQuantTable[index];
w2 = inverseQuantTable[index+1];
approxOneThird = (w1 * FACTOR) >> shift;
x1 = index << ORDER;
deltaOneThird = (w2 - w1) * (absX - x1);
deltaOneThird >>= (shift + 2);
mult_high = x * (approxOneThird + deltaOneThird);
coef[i-1] = fxp_mul32_by_16(mult_high, scale) << 1;
}
} /* if(x) */
x = quantSpec[i-2];
if (x)
{
absX = pv_abs(x);
if (absX < TABLESIZE)
{
mult_high = x * (inverseQuantTable[absX] >> shift);
coef[i-2] = fxp_mul32_by_16(mult_high, scale) << 1;
}
else
{
index = absX >> ORDER;
w1 = inverseQuantTable[index];
w2 = inverseQuantTable[index+1];
approxOneThird = (w1 * FACTOR) >> shift;
x1 = index << ORDER;
deltaOneThird = (w2 - w1) * (absX - x1);
deltaOneThird >>= (shift + 2);
mult_high = x * (approxOneThird + deltaOneThird);
coef[i-2] = fxp_mul32_by_16(mult_high, scale) << 1;
}
} /* if(x) */
x = quantSpec[i-3];
if (x)
{
absX = pv_abs(x);
if (absX < TABLESIZE)
{
mult_high = x * (inverseQuantTable[absX] >> shift);
coef[i-3] = fxp_mul32_by_16(mult_high, scale) << 1;
}
else
{
index = absX >> ORDER;
w1 = inverseQuantTable[index];
w2 = inverseQuantTable[index+1];
approxOneThird = (w1 * FACTOR) >> shift;
x1 = index << ORDER;
deltaOneThird = (w2 - w1) * (absX - x1);
deltaOneThird >>= (shift + 2);
mult_high = x * (approxOneThird + deltaOneThird);
coef[i-3] = fxp_mul32_by_16(mult_high, scale) << 1;
}
} /* if(x) */
} /* end for (i = sfbWidth - 1; i >= 0; i--) */
} /* end else for if (maxInput < TABLESIZE)*/
}
else /* scale == 0 */
{
if (maxInput < TABLESIZE)
{
for (i = sfbWidth - 1; i >= 0; i -= 4)
{
x = quantSpec[i];
y = quantSpec[i-1];
if (x)
{
absX = pv_abs(x);
mult_high = x * (inverseQuantTable[absX] >> shift);
coef[i] = mult_high >> 1;
}
if (y)
{
absX = pv_abs(y);
mult_high = y * (inverseQuantTable[absX] >> shift);
coef[i-1] = mult_high >> 1;
}
x = quantSpec[i-2];
y = quantSpec[i-3];
if (x)
{
absX = pv_abs(x);
mult_high = x * (inverseQuantTable[absX] >> shift);
coef[i-2] = mult_high >> 1;
}
if (y)
{
absX = pv_abs(y);
mult_high = y * (inverseQuantTable[absX] >> shift);
coef[i-3] = mult_high >> 1;
}
}
} /* end if (maxInput < TABLESIZE)*/
else /* maxInput >= TABLESIZE) */
{
for (i = sfbWidth - 1; i >= 0; i -= 4)
{
x = quantSpec[i];
if (x)
{
absX = pv_abs(x);
if (absX < TABLESIZE)
{
mult_high = x * (inverseQuantTable[absX] >> shift);
coef[i] = (mult_high >> 1);
} /* end if (absX < TABLESIZE) */
else
{
index = absX >> ORDER;
w1 = inverseQuantTable[index];
w2 = inverseQuantTable[index+1];
approxOneThird = (w1 * FACTOR) >> shift;
x1 = index << ORDER;
deltaOneThird = (w2 - w1) * (absX - x1);
deltaOneThird >>= (shift + 2);
mult_high = x * (approxOneThird + deltaOneThird);
coef[i] = (mult_high >> 1);
}
} /* if(x) */
x = quantSpec[i-1];
if (x)
{
absX = pv_abs(x);
if (absX < TABLESIZE)
{
mult_high = x * (inverseQuantTable[absX] >> shift);
coef[i-1] = (mult_high >> 1);
} /* end if (absX < TABLESIZE) */
else
{
index = absX >> ORDER;
w1 = inverseQuantTable[index];
w2 = inverseQuantTable[index+1];
approxOneThird = (w1 * FACTOR) >> shift;
x1 = index << ORDER;
deltaOneThird = (w2 - w1) * (absX - x1);
deltaOneThird >>= (shift + 2);
mult_high = x * (approxOneThird + deltaOneThird);
coef[i-1] = (mult_high >> 1);
}
} /* if(x) */
x = quantSpec[i-2];
if (x)
{
absX = pv_abs(x);
if (absX < TABLESIZE)
{
mult_high = x * (inverseQuantTable[absX] >> shift);
coef[i-2] = (mult_high >> 1);
} /* end if (absX < TABLESIZE) */
else
{
index = absX >> ORDER;
w1 = inverseQuantTable[index];
w2 = inverseQuantTable[index+1];
approxOneThird = (w1 * FACTOR) >> shift;
x1 = index << ORDER;
deltaOneThird = (w2 - w1) * (absX - x1);
deltaOneThird >>= (shift + 2);
mult_high = x * (approxOneThird + deltaOneThird);
coef[i-2] = (mult_high >> 1);
}
} /* if(x) */
x = quantSpec[i-3];
if (x)
{
absX = pv_abs(x);
if (absX < TABLESIZE)
{
mult_high = x * (inverseQuantTable[absX] >> shift);
coef[i-3] = (mult_high >> 1);
} /* end if (absX < TABLESIZE) */
else
{
index = absX >> ORDER;
w1 = inverseQuantTable[index];
w2 = inverseQuantTable[index+1];
approxOneThird = (w1 * FACTOR) >> shift;
x1 = index << ORDER;
deltaOneThird = (w2 - w1) * (absX - x1);
deltaOneThird >>= (shift + 2);
mult_high = x * (approxOneThird + deltaOneThird);
coef[i-3] = (mult_high >> 1);
}
} /* if(x) */
} /* end for (i = sfbWidth - 1; i >= 0; i--) */
} /* end else for if (maxInput < TABLESIZE)*/
} /* end else for if(scale!=0) */
} /* end else for if(maxInput == 0) */
} /* end esc_iquant_fxp */

View File

@@ -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.
* -------------------------------------------------------------------
*/
/*
Pathname: ./include/esc_iquant_scaling.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
Header file for esc_iquant_scaling.c
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef ESC_IQUANT_SCALING_H
#define ESC_IQUANT_SCALING_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
{
#endif
void esc_iquant_scaling(
const Int16 quantSpec[],
Int32 coef[],
const Int sfbWidth,
Int const pQFormat,
UInt16 scale,
Int maxInput);
#ifdef __cplusplus
}
#endif
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif /* ESC_IQUANT_SCALING_H */

View File

@@ -0,0 +1,487 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: extractframeInfo.c
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Arguments: hBitBuf - bitbuffer handle
v_frame_info - pointer to memorylocation where the frame-info will
be stored.
Return: none.
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
Extracts a frame_info vector from control data read from the bitstream.
------------------------------------------------------------------------------
REQUIREMENTS
------------------------------------------------------------------------------
REFERENCES
SC 29 Software Copyright Licencing Disclaimer:
This software module was originally developed by
Coding Technologies
and edited by
-
in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
standards for reference purposes and its performance may not have been
optimized. This software module is an implementation of one or more tools as
specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
ISO/IEC gives users free license to this software module or modifications
thereof for use in products claiming conformance to audiovisual and
image-coding related ITU Recommendations and/or ISO/IEC International
Standards. ISO/IEC gives users the same free license to this software module or
modifications thereof for research purposes and further ISO/IEC standardisation.
Those intending to use this software module in products are advised that its
use may infringe existing patents. ISO/IEC have no liability for use of this
software module or modifications thereof. Copyright is not released for
products that do not conform to audiovisual and image-coding related ITU
Recommendations and/or ISO/IEC International Standards.
The original developer retains full right to modify and use the code for its
own purpose, assign or donate the code to a third party and to inhibit third
parties from using the code for products that do not conform to audiovisual and
image-coding related ITU Recommendations and/or ISO/IEC International Standards.
This copyright notice must be included in all copies or derivative works.
Copyright (c) ISO/IEC 2002.
------------------------------------------------------------------------------
PSEUDO-CODE
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#ifdef AAC_PLUS
#include "extractframeinfo.h"
#include "buf_getbits.h"
#include "aac_mem_funcs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*
* (int) ceil (log (bs_num_env + 1) / log (2))
* ceil(log([0:5]+1)/log(2))
*/
const Int32 bs_pointer_bits_tbl[MAX_ENVELOPES + 1] = { 0, 1, 2, 2, 3, 3};
/*
* (int)((float)numTimeSlots/bs_num_env + 0.5f)
* floor(16./[0:5] + 0.5)
*/
const Int32 T_16_ov_bs_num_env_tbl[MAX_ENVELOPES + 1] = { 2147483647, 16, 8,
5, 4, 3
};
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
SBR_ERROR extractFrameInfo(BIT_BUFFER * hBitBuf,
SBR_FRAME_DATA * h_frame_data)
{
Int32 absBordLead = 0;
Int32 nRelLead = 0;
Int32 nRelTrail = 0;
Int32 bs_num_env = 0;
Int32 bs_num_rel = 0;
Int32 bs_var_bord = 0;
Int32 bs_var_bord_0 = 0;
Int32 bs_var_bord_1 = 0;
Int32 bs_pointer = 0;
Int32 bs_pointer_bits;
Int32 frameClass;
Int32 temp;
Int32 env;
Int32 k;
Int32 bs_num_rel_0 = 0;
Int32 bs_num_rel_1 = 0;
Int32 absBordTrail = 0;
Int32 middleBorder = 0;
Int32 bs_num_noise;
Int32 lA = 0;
Int32 tE[MAX_ENVELOPES + 1];
Int32 tQ[2 + 1];
Int32 f[MAX_ENVELOPES + 1];
Int32 bs_rel_bord[3];
Int32 bs_rel_bord_0[3];
Int32 bs_rel_bord_1[3];
Int32 relBordLead[3];
Int32 relBordTrail[3];
Int32 *v_frame_info = h_frame_data->frameInfo;
SBR_ERROR err = SBRDEC_OK;
/*
* First read from the bitstream.
*/
/* Read frame class */
h_frame_data->frameClass = frameClass = buf_getbits(hBitBuf, SBR_CLA_BITS);
switch (frameClass)
{
case FIXFIX:
temp = buf_getbits(hBitBuf, SBR_ENV_BITS); /* 2 bits */
bs_num_env = 1 << temp;
f[0] = buf_getbits(hBitBuf, SBR_RES_BITS); /* 1 bit */
for (env = 1; env < bs_num_env; env++)
{
f[env] = f[0];
}
nRelLead = bs_num_env - 1;
absBordTrail = 16;
break;
case FIXVAR:
bs_var_bord = buf_getbits(hBitBuf, SBR_ABS_BITS); /* 2 bits */
bs_num_rel = buf_getbits(hBitBuf, SBR_NUM_BITS); /* 2 bits */
bs_num_env = bs_num_rel + 1;
for (k = 0; k < bs_num_env - 1; k++)
{
bs_rel_bord[k] = (buf_getbits(hBitBuf, SBR_REL_BITS) + 1) << 1;
}
bs_pointer_bits = bs_pointer_bits_tbl[bs_num_env];
bs_pointer = buf_getbits(hBitBuf, bs_pointer_bits);
for (env = 0; env < bs_num_env; env++)
{ /* 1 bit */
f[bs_num_env - 1 - env] = buf_getbits(hBitBuf, SBR_RES_BITS);
}
absBordTrail = 16 + bs_var_bord;
nRelTrail = bs_num_rel;
break;
case VARFIX:
bs_var_bord = buf_getbits(hBitBuf, SBR_ABS_BITS); /* 2 bits */
bs_num_rel = buf_getbits(hBitBuf, SBR_NUM_BITS); /* 2 bits */
bs_num_env = bs_num_rel + 1;
for (k = 0; k < bs_num_env - 1; k++)
{
bs_rel_bord[k] = (buf_getbits(hBitBuf, SBR_REL_BITS) + 1) << 1;
}
bs_pointer_bits = bs_pointer_bits_tbl[bs_num_env];
bs_pointer = buf_getbits(hBitBuf, bs_pointer_bits);
for (env = 0; env < bs_num_env; env++)
{ /* 1 bit */
f[env] = buf_getbits(hBitBuf, SBR_RES_BITS);
}
absBordTrail = 16;
absBordLead = bs_var_bord;
nRelLead = bs_num_rel;
break;
case VARVAR:
bs_var_bord_0 = buf_getbits(hBitBuf, SBR_ABS_BITS); /* 2 bits */
bs_var_bord_1 = buf_getbits(hBitBuf, SBR_ABS_BITS);
bs_num_rel_0 = buf_getbits(hBitBuf, SBR_NUM_BITS); /* 2 bits */
bs_num_rel_1 = buf_getbits(hBitBuf, SBR_NUM_BITS);
bs_num_env = bs_num_rel_0 + bs_num_rel_1 + 1;
for (k = 0; k < bs_num_rel_0; k++)
{ /* 2 bits */
bs_rel_bord_0[k] = (buf_getbits(hBitBuf, SBR_REL_BITS) + 1) << 1;
}
for (k = 0; k < bs_num_rel_1; k++)
{ /* 2 bits */
bs_rel_bord_1[k] = (buf_getbits(hBitBuf, SBR_REL_BITS) + 1) << 1;
}
bs_pointer_bits = bs_pointer_bits_tbl[bs_num_env];
bs_pointer = buf_getbits(hBitBuf, bs_pointer_bits);
for (env = 0; env < bs_num_env; env++)
{ /* 1 bit */
f[env] = buf_getbits(hBitBuf, SBR_RES_BITS);
}
absBordLead = bs_var_bord_0;
absBordTrail = 16 + bs_var_bord_1;
nRelLead = bs_num_rel_0;
nRelTrail = bs_num_rel_1;
break;
};
/*
* Calculate the framing.
*/
switch (frameClass)
{
case FIXFIX:
for (k = 0; k < nRelLead; k++)
{
relBordLead[k] = T_16_ov_bs_num_env_tbl[bs_num_env];
}
break;
case VARFIX:
for (k = 0; k < nRelLead; k++)
{
relBordLead[k] = bs_rel_bord[k];
}
break;
case VARVAR:
for (k = 0; k < nRelLead; k++)
{
relBordLead[k] = bs_rel_bord_0[k];
}
for (k = 0; k < nRelTrail; k++)
{
relBordTrail[k] = bs_rel_bord_1[k];
}
break;
case FIXVAR:
for (k = 0; k < nRelTrail; k++)
{
relBordTrail[k] = bs_rel_bord[k];
}
break;
}
tE[0] = absBordLead;
tE[bs_num_env] = absBordTrail;
for (env = 1; env <= nRelLead; env++)
{
tE[env] = absBordLead;
for (k = 0; k <= env - 1; k++)
{
tE[env] += relBordLead[k];
}
}
for (env = nRelLead + 1; env < bs_num_env; env++)
{
tE[env] = absBordTrail;
for (k = 0; k <= bs_num_env - env - 1; k++)
{
tE[env] -= relBordTrail[k];
}
}
switch (frameClass)
{
case FIXFIX:
middleBorder = bs_num_env >> 1;
break;
case VARFIX:
switch (bs_pointer)
{
case 0:
middleBorder = 1;
break;
case 1:
middleBorder = bs_num_env - 1;
break;
default:
middleBorder = bs_pointer - 1;
break;
};
break;
case FIXVAR:
case VARVAR:
switch (bs_pointer)
{
case 0:
case 1:
middleBorder = bs_num_env - 1;
break;
default:
middleBorder = bs_num_env + 1 - bs_pointer;
break;
};
break;
};
tQ[0] = tE[0];
if (bs_num_env > 1)
{
tQ[1] = tE[middleBorder];
tQ[2] = tE[bs_num_env];
bs_num_noise = 2;
}
else
{
tQ[1] = tE[bs_num_env];
bs_num_noise = 1;
}
/*
* Check consistency on freq bands
*/
if ((tE[bs_num_env] < tE[0]) || (tE[0] < 0))
{
err = SBRDEC_INVALID_BITSTREAM;
}
switch (frameClass)
{
case FIXFIX:
lA = -1;
break;
case VARFIX:
switch (bs_pointer)
{
case 0:
case 1:
lA = -1;
break;
default:
lA = bs_pointer - 1;
break;
};
break;
case FIXVAR:
case VARVAR:
switch (bs_pointer)
{
case 0:
lA = - 1;
break;
default:
lA = bs_num_env + 1 - bs_pointer;
break;
};
break;
};
/*
* Build the frameInfo vector...
*/
v_frame_info[0] = bs_num_env; /* Number of envelopes*/
pv_memcpy(v_frame_info + 1, tE, (bs_num_env + 1)*sizeof(Int32)); /* time borders*/
/* frequency resolution */
pv_memcpy(v_frame_info + 1 + bs_num_env + 1, f, bs_num_env*sizeof(Int32));
temp = (1 + bs_num_env) << 1;
v_frame_info[temp] = lA; /* transient envelope*/
v_frame_info[temp + 1] = bs_num_noise; /* Number of noise envelopes */
/* noise borders */
pv_memcpy(v_frame_info + temp + 2, tQ, (bs_num_noise + 1)*sizeof(Int32));
return (err);
}
#endif

View File

@@ -0,0 +1,96 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Filename: extractFrameInfo.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef EXTRACTFRAMEINFO_H
#define EXTRACTFRAMEINFO_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "s_bit_buffer.h"
#include "s_sbr_frame_data.h"
#include "e_sbr_error.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
typedef Int32 FRAME_INFO[LENGTH_FRAME_INFO];
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
{
#endif
SBR_ERROR extractFrameInfo(BIT_BUFFER * hBitBuf,
SBR_FRAME_DATA * h_frame_data);
#ifdef __cplusplus
}
#endif
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -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.
* -------------------------------------------------------------------
*/
/*
Pathname: ./include/fft_rx4.h
------------------------------------------------------------------------------
REVISION HISTORY
(1) modified definition of w_64rx4 from Int to Int16
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
Header file for functions fft_rx4()
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef FFT_RX4_H
#define FFT_RX4_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
#define FFT_RX4_LONG 256
#define ONE_FOURTH_FFT_RX4_LONG ((FFT_RX4_LONG)>>2)
#define FFT_RX4_SHORT 64
#define ONE_FOURTH_FFT_RX4_SHORT ((FFT_RX4_SHORT)>>2)
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
extern const Int16 w_64rx4[];
extern const Int32 W_64rx4[];
extern const Int32 W_256rx4[];
extern const Int32 w_512rx2[];
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
{
#endif
void fft_rx4_long(
Int32 Data[],
Int32 *peak_value);
Int fft_rx4_short(
Int32 Data[],
Int32 *peak_value);
#ifdef __cplusplus
}
#endif
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif /* FFT_RX4_H */

View File

@@ -0,0 +1,428 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./src/fft_rx4_long.c
Funtions: fft_rx4_long
------------------------------------------------------------------------------
REVISION HISTORY
Description:
(1) Eliminated search for max in the main loop.
(2) Reduced precision on w_256rx4 from Q15 to Q10
Description:
(1) Created function fft_rx4_long_no_max to overcome LTP problem.
Description:
(1) Modified shift so the accumulation growths faster than the
downshift, so now the input can be as high as 1.0 and saturation
will not occurre. The accumulation times the Q10 format will
never exceed 31 bits. This increases precision
(2) Eliminated unneeded data moves, used before for max search.
(3) Eliminated function fft_rx4_long_no_max.
Description:
(1) Added comment to explain max search elimination and
Q format during multiplications
Who: Date:
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Inputs:
Data = Input complex vector, arranged in the following order:
real, imag, real, imag...
This is a complex vector whose elements (real and Imag) are
Int32.
type Int32 *
peak_value = Input, peak value of the input vector
Output, peak value of the resulting vector
type Int32 *
Local Stores/Buffers/Pointers Needed:
None
Global Stores/Buffers/Pointers Needed:
None
Outputs:
None
Pointers and Buffers Modified:
calculation are done in-place and returned in Data
Local Stores Modified:
None
Global Stores Modified:
None
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
Fast Fourier Transform, radix 4 with Decimation in Frequency and block
floating point arithmetic.
The radix-4 FFT simply divides the FFT into four smaller FFTs. Each of
the smaller FFTs is then further divided into smaller ones and so on.
It consists of log 4 N stages and each stage consists of N/4 dragonflies.
An FFT is nothing but a bundle of multiplications and summations which
may overflow during calculations.
This routine uses a scheme to test and scale the result output from
each FFT stage in order to fix the accumulation overflow.
The Input Data should be in Q13 format to get the highest precision.
At the end of each dragonfly calculation, a test for possible bit growth
is made, if bit growth is possible the Data is scale down back to Q13.
------------------------------------------------------------------------------
REQUIREMENTS
This function should provide a fixed point FFT for an input array
of size 256.
------------------------------------------------------------------------------
REFERENCES
[1] Advance Digital Signal Processing, J. Proakis, C. Rader, F. Ling,
C. Nikias, Macmillan Pub. Co.
------------------------------------------------------------------------------
PSEUDO-CODE
MODIFY( x[] )
RETURN( exponent )
------------------------------------------------------------------------------
RESOURCES USED
When the code is written for a specific target processor the
the resources used should be documented below.
STACK USAGE: [stack count for this module] + [variable to represent
stack usage for each subroutine called]
where: [stack usage variable] = stack usage for [subroutine
name] (see [filename].ext)
DATA MEMORY USED: x words
PROGRAM MEMORY USED: x words
CLOCK CYCLES: [cycle count equation for this module] + [variable
used to represent cycle count for each subroutine
called]
where: [cycle count variable] = cycle count for [subroutine
name] (see [filename].ext)
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "fft_rx4.h"
#include "fxp_mul32.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL VARIABLE DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
void fft_rx4_long(
Int32 Data[],
Int32 *peak_value)
{
Int n1;
Int n2;
Int j;
Int k;
Int i;
Int32 t1;
Int32 t2;
Int32 r1;
Int32 r2;
Int32 r3;
Int32 r4;
Int32 s1;
Int32 s2;
Int32 s3;
Int32 *pData1;
Int32 *pData2;
Int32 *pData3;
Int32 *pData4;
Int32 temp1;
Int32 temp2;
Int32 temp3;
Int32 temp4;
Int32 max;
Int32 exp_jw1;
Int32 exp_jw2;
Int32 exp_jw3;
const Int32 *pw = W_256rx4;
n2 = FFT_RX4_LONG;
for (k = FFT_RX4_LONG; k > 4; k >>= 2)
{
n1 = n2;
n2 >>= 2;
for (i = 0; i < FFT_RX4_LONG; i += n1)
{
pData1 = &Data[ i<<1];
pData2 = pData1 + n1;
temp1 = *pData1;
temp2 = *pData2;
r1 = temp1 + temp2;
r2 = temp1 - temp2;
pData3 = pData1 + (n1 >> 1);
pData4 = pData3 + n1;
temp3 = *pData3++;
temp4 = *pData4++;
t1 = temp3 + temp4;
*(pData1++) = (r1 + t1);
t2 = temp3 - temp4;
*(pData2++) = (r1 - t1);
temp1 = *pData1;
temp2 = *pData2;
s1 = temp1 + temp2;
temp3 = *pData3;
s2 = temp1 - temp2;
temp4 = *pData4;
*pData3-- = (s2 - t2);
*pData4-- = (s2 + t2);
t1 = temp3 + temp4;
*pData1 = (s1 + t1);
*pData2 = (s1 - t1);
r1 = temp3 - temp4;
*pData4 = (r2 - r1);
*pData3 = (r2 + r1);
} /* i */
for (j = 1; j < n2; j++)
{
exp_jw1 = (*pw++);
exp_jw2 = (*pw++);
exp_jw3 = (*pw++);
for (i = j; i < FFT_RX4_LONG; i += n1)
{
pData1 = &Data[ i<<1];
pData2 = pData1 + n1;
temp1 = *pData1;
temp2 = *pData2++;
r1 = temp1 + temp2;
r2 = temp1 - temp2;
pData3 = pData1 + (n1 >> 1);
pData4 = pData3 + n1;
temp3 = *pData3++;
temp4 = *pData4++;
r3 = temp3 + temp4;
r4 = temp3 - temp4;
*(pData1++) = (r1 + r3);
r1 = (r1 - r3) << 1;
temp2 = *pData2;
temp1 = *pData1;
s1 = temp1 + temp2;
s2 = temp1 - temp2;
s3 = (s2 + r4) << 1;
s2 = (s2 - r4) << 1;
temp3 = *pData3;
temp4 = *pData4;
t1 = temp3 + temp4;
t2 = temp3 - temp4;
*pData1 = (s1 + t1);
s1 = (s1 - t1) << 1;
*pData2-- = cmplx_mul32_by_16(s1, -r1, exp_jw2);
r3 = (r2 - t2) << 1;
*pData2 = cmplx_mul32_by_16(r1, s1, exp_jw2);
r2 = (r2 + t2) << 1;
*pData3-- = cmplx_mul32_by_16(s2, -r2, exp_jw1);
*pData3 = cmplx_mul32_by_16(r2, s2, exp_jw1);
*pData4-- = cmplx_mul32_by_16(s3, -r3, exp_jw3);
*pData4 = cmplx_mul32_by_16(r3, s3, exp_jw3);
} /* i */
} /* j */
} /* k */
max = 0;
pData1 = Data - 7;
for (i = ONE_FOURTH_FFT_RX4_LONG; i != 0 ; i--)
{
pData1 += 7;
pData2 = pData1 + 4;
temp1 = *pData1;
temp2 = *pData2++;
r1 = temp1 + temp2;
r2 = temp1 - temp2;
pData3 = pData1 + 2;
pData4 = pData1 + 6;
temp1 = *pData3++;
temp2 = *pData4++;
t1 = temp1 + temp2;
t2 = temp1 - temp2;
temp1 = (r1 + t1);
r1 = (r1 - t1);
*(pData1++) = temp1;
max |= (temp1 >> 31) ^ temp1;
temp2 = *pData2;
temp1 = *pData1;
s1 = temp1 + temp2;
s2 = temp1 - temp2;
temp1 = *pData3;
temp2 = *pData4;
s3 = (s2 + t2);
s2 = (s2 - t2);
t1 = temp1 + temp2;
t2 = temp1 - temp2;
temp1 = (s1 + t1);
*pData1 = temp1;
temp2 = (s1 - t1);
max |= (temp1 >> 31) ^ temp1;
*pData2-- = temp2;
max |= (temp2 >> 31) ^ temp2;
*pData2 = r1;
max |= (r1 >> 31) ^ r1;
*pData3-- = s2;
max |= (s2 >> 31) ^ s2;
*pData4-- = s3;
max |= (s3 >> 31) ^ s3;
temp1 = (r2 - t2);
*pData4 = temp1;
temp2 = (r2 + t2);
*pData3 = temp2;
max |= (temp1 >> 31) ^ temp1;
max |= (temp2 >> 31) ^ temp2;
} /* i */
*peak_value = max;
return ;
}

View File

@@ -0,0 +1,468 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./src/fft_rx4_short.c
Funtions: fft_rx4_short
------------------------------------------------------------------------------
REVISION HISTORY
Description:
(1) Eliminated search for max in the main loop.
(2) Simplified the function by eliminating different conditions
for exp.
(3) Reduced precision on w_64rx4 from Q15 to Q12, so now the
input can be as high as 1.0 and saturation will not occurre
because the accumulation times the new Q12 format will never
exceed 31 bits.
Description:
(1) Added comment to explain max search elimination and
Q format during multiplications
(2) Increased down shift from 1 to 2, to ensure that 32-bit
numbers will not overflow when 2 consecutive adds are done
This was found during code review.
Who: Date:
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Inputs:
Data = Input complex vector, arranged in the following order:
real, imag, real, imag...
This is a complex vector whose elements (real and Imag) are
Int32.
type Int32 *
peak_value = Input, peak value of the input vector
Output, peak value of the resulting vector
type Int32 *
Local Stores/Buffers/Pointers Needed:
None
Global Stores/Buffers/Pointers Needed:
None
Outputs:
exponent returns a shift to compensate the scaling introduced by
overflow protection
Pointers and Buffers Modified:
calculation are done in-place and returned in Data
Local Stores Modified:
None
Global Stores Modified:
None
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
Fast Fourier Transform, radix 4 with Decimation in Frequency and block
floating point arithmetic.
The radix-4 FFT simply divides the FFT into four smaller FFTs. Each of
the smaller FFTs is then further divided into smaller ones and so on.
It consists of log 4 N stages and each stage consists of N/4 dragonflies.
An FFT is nothing but a bundle of multiplications and summations which
may overflow during calculations.
This routine uses a scheme to test and scale the result output from
each FFT stage in order to fix the accumulation overflow.
The Input Data should be in Q13 format to get the highest precision.
At the end of each dragonfly calculation, a test for possible bit growth
is made, if bit growth is possible the Data is scale down back to Q13.
------------------------------------------------------------------------------
REQUIREMENTS
This function should provide a fixed point FFT for an input array
of size 64.
------------------------------------------------------------------------------
REFERENCES
[1] Advance Digital Signal Processing, J. Proakis, C. Rader, F. Ling,
C. Nikias, Macmillan Pub. Co.
------------------------------------------------------------------------------
PSEUDO-CODE
MODIFY( x[] )
RETURN( exponent )
------------------------------------------------------------------------------
RESOURCES USED
When the code is written for a specific target processor the
the resources used should be documented below.
STACK USAGE: [stack count for this module] + [variable to represent
stack usage for each subroutine called]
where: [stack usage variable] = stack usage for [subroutine
name] (see [filename].ext)
DATA MEMORY USED: x words
PROGRAM MEMORY USED: x words
CLOCK CYCLES: [cycle count equation for this module] + [variable
used to represent cycle count for each subroutine
called]
where: [cycle count variable] = cycle count for [subroutine
name] (see [filename].ext)
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "fft_rx4.h"
#include "pv_normalize.h"
#include "fxp_mul32.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL VARIABLE DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
Int fft_rx4_short(
Int32 Data[],
Int32 *peak_value)
{
Int n1;
Int n2;
Int n3;
Int j;
Int k;
Int i;
Int32 exp_jw1;
Int32 exp_jw2;
Int32 exp_jw3;
Int32 t1;
Int32 t2;
Int32 r1;
Int32 r2;
Int32 r3;
Int32 s1;
Int32 s2;
Int32 s3;
Int32 *pData1;
Int32 *pData2;
Int32 *pData3;
Int32 *pData4;
const Int32 *pw;
Int32 temp1;
Int32 temp2;
Int32 temp3;
Int32 temp4;
Int32 max;
Int exp;
Int exponent = 0;
Int shift;
max = *peak_value;
exp = 0;
if (max > 0x008000)
{
exp = 8 - pv_normalize(max); /* use 24 bits */
exponent = exp; /* keeps track of # of shifts */
}
n2 = FFT_RX4_SHORT;
pw = W_64rx4;
/* shift down to avoid possible overflow in first pass of the loop */
shift = 2;
for (k = FFT_RX4_SHORT; k > 4; k >>= 2)
{
n1 = n2;
n2 >>= 2;
n3 = n1 >> 1;
exp -= 2;
for (i = 0; i < FFT_RX4_SHORT; i += n1)
{
pData1 = &Data[ i<<1];
pData3 = pData1 + n3;
pData2 = pData1 + n1;
pData4 = pData3 + n1;
temp1 = *(pData1);
temp2 = *(pData2);
temp1 >>= shift;
temp2 >>= shift;
r1 = temp1 + temp2;
r2 = temp1 - temp2;
temp3 = *(pData3++);
temp4 = *(pData4++);
temp3 >>= shift;
temp4 >>= shift;
t1 = temp3 + temp4;
t2 = temp3 - temp4;
*(pData1++) = (r1 + t1) >> exp;
*(pData2++) = (r1 - t1) >> exp;
temp1 = *pData1;
temp2 = *pData2;
temp1 >>= shift;
temp2 >>= shift;
s1 = temp1 + temp2;
s2 = temp1 - temp2;
temp3 = *pData3;
temp4 = *pData4;
temp3 >>= shift;
temp4 >>= shift;
t1 = temp3 + temp4;
r1 = temp3 - temp4;
*pData1 = (s1 + t1) >> exp;
*pData2 = (s1 - t1) >> exp;
*pData4-- = (s2 + t2) >> exp;
*pData4 = (r2 - r1) >> exp;
*pData3-- = (s2 - t2) >> exp;
*pData3 = (r2 + r1) >> exp;
} /* i */
for (j = 1; j < n2; j++)
{
exp_jw1 = *pw++;
exp_jw2 = *pw++;
exp_jw3 = *pw++;
for (i = j; i < FFT_RX4_SHORT; i += n1)
{
pData1 = &Data[ i<<1];
pData3 = pData1 + n3;
pData2 = pData1 + n1;
pData4 = pData3 + n1;
temp1 = *(pData1);
temp2 = *(pData2++);
temp1 >>= shift;
temp2 >>= shift;
r1 = temp1 + temp2;
r2 = temp1 - temp2;
temp3 = *(pData3++);
temp4 = *(pData4++);
temp3 >>= shift;
temp4 >>= shift;
t1 = temp3 + temp4;
t2 = temp3 - temp4;
*(pData1++) = (r1 + t1) >> exp;
r1 = (r1 - t1) >> exp;
temp1 = *pData1;
temp2 = *pData2;
temp1 >>= shift;
temp2 >>= shift;
s1 = temp1 + temp2;
s2 = temp1 - temp2;
s3 = (s2 + t2) >> exp;
s2 = (s2 - t2) >> exp;
temp3 = *pData3;
temp4 = *pData4 ;
temp3 >>= shift;
temp4 >>= shift;
t1 = temp3 + temp4;
t2 = temp3 - temp4;
*pData1 = (s1 + t1) >> exp;
s1 = (s1 - t1) >> exp;
*pData2-- = cmplx_mul32_by_16(s1, -r1, exp_jw2) << 1;
*pData2 = cmplx_mul32_by_16(r1, s1, exp_jw2) << 1;
r3 = ((r2 - t2) >> exp);
r2 = ((r2 + t2) >> exp);
*pData3-- = cmplx_mul32_by_16(s2, -r2, exp_jw1) << 1;
*pData3 = cmplx_mul32_by_16(r2, s2, exp_jw1) << 1;
*pData4-- = cmplx_mul32_by_16(s3, -r3, exp_jw3) << 1;
*pData4 = cmplx_mul32_by_16(r3, s3, exp_jw3) << 1;
} /* i */
} /* j */
/*
* this will reset exp and shift to zero for the second pass of the
* loop
*/
exp = 2;
shift = 0;
} /* k */
max = 0;
pData1 = Data - 7;
for (i = ONE_FOURTH_FFT_RX4_SHORT; i != 0 ; i--)
{
pData1 += 7;
pData3 = pData1 + 2;
pData2 = pData1 + 4;
pData4 = pData1 + 6;
temp1 = *pData1;
temp2 = *pData2++;
r1 = temp1 + temp2;
r2 = temp1 - temp2;
temp1 = *pData3++;
temp2 = *pData4++;
t1 = temp1 + temp2;
t2 = temp1 - temp2;
temp1 = (r1 + t1);
r1 = (r1 - t1);
*(pData1++) = temp1;
max |= (temp1 >> 31) ^ temp1;
temp1 = *pData1;
temp2 = *pData2;
s1 = temp1 + temp2;
s2 = temp1 - temp2;
s3 = (s2 + t2);
s2 = (s2 - t2);
temp1 = *pData3;
temp2 = *pData4;
t1 = temp1 + temp2;
t2 = temp1 - temp2;
temp1 = (s1 + t1);
temp2 = (s1 - t1);
*pData1 = temp1;
*pData2-- = temp2;
max |= (temp1 >> 31) ^ temp1;
max |= (temp2 >> 31) ^ temp2;
*pData2 = r1;
*pData3-- = s2;
*pData4-- = s3;
max |= (r1 >> 31) ^ r1;
max |= (s2 >> 31) ^ s2;
max |= (s3 >> 31) ^ s3;
temp1 = (r2 - t2);
temp2 = (r2 + t2);
*pData4 = temp1;
*pData3 = temp2;
max |= (temp1 >> 31) ^ temp1;
max |= (temp2 >> 31) ^ temp2;
} /* i */
*peak_value = max;
return (exponent);
}

View File

@@ -0,0 +1,269 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./src/fft_rx4_tables_fxp.c
Funtions:
------------------------------------------------------------------------------
REVISION HISTORY
Description: Reduce the accuracy of w_256rx4 and w_512rx2 to Q10 format.
Try to to pack sin and cos into one 32-bit number to reduce the
memory access, but doesn't help in speed, so commented out for now.
Description:
(1) Reduced precision of w_64rx4 from Q15 to Q12.
(2) Increased precision of w_512rx2 from Q10 to Q13, Both changes
increase overall decoder precision
Description:
(1) per code review comment, added description for table generation
(2) modified definition of w_64rx4 from Int to Int16
Who: Date:
Description:
----------------------------------------------------------------------------
MODULE DESCRIPTION
Table generation
n = 256 or 64;
M = precision; 2^10, 2^12, 2^13
for j=1; j<log4(n); j *= 4
for i=0; i<n/4; i +=j
phi_1 = 2*pi*i/n;
phi_2 = 4*pi*i/n;
phi_3 = 6*pi*i/n;
M*[cos(phi_1) sin(phi_1) cos(phi_2) sin(phi_2) cos(phi_3) sin(phi_4)];
end
end
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "fft_rx4.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL VARIABLE DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*
------------------------------------------------------------------------------
Forward FFT radix-4 tables
------------------------------------------------------------------------------
*/
const Int32 W_64rx4[60] = /* 2 Q15 */
{
0x7F610C8C, 0x7D8918F9, 0x7A7C2528,
0x7D8918F9, 0x764130FB, 0x6A6D471C,
0x7A7C2528, 0x6A6D471C, 0x513362F1,
0x764130FB, 0x5A825A82, 0x30FB7641,
0x70E23C56, 0x471C6A6D, 0x0C8C7F61,
0x6A6D471C, 0x30FB7641, 0xE7057D89,
0x62F15133, 0x18F97D89, 0xC3A870E2,
0x5A825A82, 0x00007FFF, 0xA57C5A82,
0x513362F1, 0xE7057D89, 0x8F1C3C56,
0x471C6A6D, 0xCF037641, 0x827518F9,
0x3C5670E2, 0xB8E26A6D, 0x809DF372,
0x30FB7641, 0xA57C5A82, 0x89BDCF03,
0x25287A7C, 0x9591471C, 0x9D0DAECB,
0x18F97D89, 0x89BD30FB, 0xB8E29591,
0x0C8C7F61, 0x827518F9, 0xDAD68582,
0x764130FB, 0x5A825A82, 0x30FB7641,
0x5A825A82, 0x00007FFF, 0xA57C5A82,
0x30FB7641, 0xA57C5A82, 0x89BDCF03,
};
const Int32 W_256rx4[495] = /* 2 Q15 */
{
0x7FF50324, 0x7FD80648, 0x7FA6096A,
0x7FD80648, 0x7F610C8C, 0x7E9C12C8,
0x7FA6096A, 0x7E9C12C8, 0x7CE31C0B,
0x7F610C8C, 0x7D8918F9, 0x7A7C2528,
0x7F090FAB, 0x7C291F1A, 0x776B2E11,
0x7E9C12C8, 0x7A7C2528, 0x73B536BA,
0x7E1D15E2, 0x78842B1F, 0x6F5E3F17,
0x7D8918F9, 0x764130FB, 0x6A6D471C,
0x7CE31C0B, 0x73B536BA, 0x64E84EBF,
0x7C291F1A, 0x70E23C56, 0x5ED755F5,
0x7B5C2223, 0x6DC941CE, 0x58425CB3,
0x7A7C2528, 0x6A6D471C, 0x513362F1,
0x79892826, 0x66CF4C3F, 0x49B468A6,
0x78842B1F, 0x62F15133, 0x41CE6DC9,
0x776B2E11, 0x5ED755F5, 0x398C7254,
0x764130FB, 0x5A825A82, 0x30FB7641,
0x750433DF, 0x55F55ED7, 0x28267989,
0x73B536BA, 0x513362F1, 0x1F1A7C29,
0x7254398C, 0x4C3F66CF, 0x15E27E1D,
0x70E23C56, 0x471C6A6D, 0x0C8C7F61,
0x6F5E3F17, 0x41CE6DC9, 0x03247FF5,
0x6DC941CE, 0x3C5670E2, 0xF9B67FD8,
0x6C23447A, 0x36BA73B5, 0xF0537F09,
0x6A6D471C, 0x30FB7641, 0xE7057D89,
0x68A649B4, 0x2B1F7884, 0xDDDB7B5C,
0x66CF4C3F, 0x25287A7C, 0xD4DF7884,
0x64E84EBF, 0x1F1A7C29, 0xCC1F7504,
0x62F15133, 0x18F97D89, 0xC3A870E2,
0x60EB539B, 0x12C87E9C, 0xBB846C23,
0x5ED755F5, 0x0C8C7F61, 0xB3BF66CF,
0x5CB35842, 0x06487FD8, 0xAC6360EB,
0x5A825A82, 0x00007FFF, 0xA57C5A82,
0x58425CB3, 0xF9B67FD8, 0x9F13539B,
0x55F55ED7, 0xF3727F61, 0x992F4C3F,
0x539B60EB, 0xED367E9C, 0x93DB447A,
0x513362F1, 0xE7057D89, 0x8F1C3C56,
0x4EBF64E8, 0xE0E47C29, 0x8AFA33DF,
0x4C3F66CF, 0xDAD67A7C, 0x877A2B1F,
0x49B468A6, 0xD4DF7884, 0x84A22223,
0x471C6A6D, 0xCF037641, 0x827518F9,
0x447A6C23, 0xC94473B5, 0x80F50FAB,
0x41CE6DC9, 0xC3A870E2, 0x80260648,
0x3F176F5E, 0xBE306DC9, 0x8009FCDA,
0x3C5670E2, 0xB8E26A6D, 0x809DF372,
0x398C7254, 0xB3BF66CF, 0x81E1EA1C,
0x36BA73B5, 0xAECB62F1, 0x83D5E0E4,
0x33DF7504, 0xAA095ED7, 0x8675D7D8,
0x30FB7641, 0xA57C5A82, 0x89BDCF03,
0x2E11776B, 0xA12755F5, 0x8DAAC672,
0x2B1F7884, 0x9D0D5133, 0x9235BE30,
0x28267989, 0x992F4C3F, 0x9758B64A,
0x25287A7C, 0x9591471C, 0x9D0DAECB,
0x22237B5C, 0x923541CE, 0xA34BA7BC,
0x1F1A7C29, 0x8F1C3C56, 0xAA09A127,
0x1C0B7CE3, 0x8C4936BA, 0xB13F9B16,
0x18F97D89, 0x89BD30FB, 0xB8E29591,
0x15E27E1D, 0x877A2B1F, 0xC0E790A0,
0x12C87E9C, 0x85822528, 0xC9448C49,
0x0FAB7F09, 0x83D51F1A, 0xD1ED8893,
0x0C8C7F61, 0x827518F9, 0xDAD68582,
0x096A7FA6, 0x816212C8, 0xE3F3831B,
0x06487FD8, 0x809D0C8C, 0xED368162,
0x03247FF5, 0x80260648, 0xF6948058,
0x7F610C8C, 0x7D8918F9, 0x7A7C2528,
0x7D8918F9, 0x764130FB, 0x6A6D471C,
0x7A7C2528, 0x6A6D471C, 0x513362F1,
0x764130FB, 0x5A825A82, 0x30FB7641,
0x70E23C56, 0x471C6A6D, 0x0C8C7F61,
0x6A6D471C, 0x30FB7641, 0xE7057D89,
0x62F15133, 0x18F97D89, 0xC3A870E2,
0x5A825A82, 0x00007FFF, 0xA57C5A82,
0x513362F1, 0xE7057D89, 0x8F1C3C56,
0x471C6A6D, 0xCF037641, 0x827518F9,
0x3C5670E2, 0xB8E26A6D, 0x809DF372,
0x30FB7641, 0xA57C5A82, 0x89BDCF03,
0x25287A7C, 0x9591471C, 0x9D0DAECB,
0x18F97D89, 0x89BD30FB, 0xB8E29591,
0x0C8C7F61, 0x827518F9, 0xDAD68582,
0x764130FB, 0x5A825A82, 0x30FB7641,
0x5A825A82, 0x00007FFF, 0xA57C5A82,
0x30FB7641, 0xA57C5A82, 0x89BDCF03
};
/*
------------------------------------------------------------------------------
Forward FFT radix-2 table
------------------------------------------------------------------------------
*/
const Int32 w_512rx2[127] =
{
/* Q15 */
0x7FFE0192, 0x7FF60324, 0x7FEA04B6,
0x7FD90648, 0x7FC207D9, 0x7FA7096B, 0x7F870AFB,
0x7F620C8C, 0x7F380E1C, 0x7F0A0FAB, 0x7ED6113A,
0x7E9D12C8, 0x7E601455, 0x7E1E15E2, 0x7DD6176E,
0x7D8A18F9, 0x7D3A1A83, 0x7CE41C0C, 0x7C891D93,
0x7C2A1F1A, 0x7BC6209F, 0x7B5D2224, 0x7AEF23A7,
0x7A7D2528, 0x7A0626A8, 0x798A2827, 0x790A29A4,
0x78852B1F, 0x77FB2C99, 0x776C2E11, 0x76D92F87,
0x764230FC, 0x75A6326E, 0x750533DF, 0x7460354E,
0x73B636BA, 0x73083825, 0x7255398D, 0x719E3AF3,
0x70E33C57, 0x70233DB8, 0x6F5F3F17, 0x6E974074,
0x6DCA41CE, 0x6CF94326, 0x6C24447B, 0x6B4B45CD,
0x6A6E471D, 0x698C486A, 0x68A749B4, 0x67BD4AFB,
0x66D04C40, 0x65DE4D81, 0x64E94EC0, 0x63EF4FFB,
0x62F25134, 0x61F15269, 0x60EC539B, 0x5FE454CA,
0x5ED755F6, 0x5DC8571E, 0x5CB45843, 0x5B9D5964,
0x5A825A82, 0x59645B9D, 0x58435CB4, 0x571E5DC8,
0x55F65ED7, 0x54CA5FE4, 0x539B60EC, 0x526961F1,
0x513462F2, 0x4FFB63EF, 0x4EC064E9, 0x4D8165DE,
0x4C4066D0, 0x4AFB67BD, 0x49B468A7, 0x486A698C,
0x471D6A6E, 0x45CD6B4B, 0x447B6C24, 0x43266CF9,
0x41CE6DCA, 0x40746E97, 0x3F176F5F, 0x3DB87023,
0x3C5770E3, 0x3AF3719E, 0x398D7255, 0x38257308,
0x36BA73B6, 0x354E7460, 0x33DF7505, 0x326E75A6,
0x30FC7642, 0x2F8776D9, 0x2E11776C, 0x2C9977FB,
0x2B1F7885, 0x29A4790A, 0x2827798A, 0x26A87A06,
0x25287A7D, 0x23A77AEF, 0x22247B5D, 0x209F7BC6,
0x1F1A7C2A, 0x1D937C89, 0x1C0C7CE4, 0x1A837D3A,
0x18F97D8A, 0x176E7DD6, 0x15E27E1E, 0x14557E60,
0x12C87E9D, 0x113A7ED6, 0x0FAB7F0A, 0x0E1C7F38,
0x0C8C7F62, 0x0AFB7F87, 0x096B7FA7, 0x07D97FC2,
0x06487FD9, 0x04B67FEA, 0x03247FF6, 0x01927FFE
};

View File

@@ -0,0 +1,305 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./src/find_adts_syncword.c
------------------------------------------------------------------------------
REVISION HISTORY
Description: Fixed error in logic that determines whether there are enough
bits available to conduct a search for the syncword. The plus sign in
the following condition should be a minus.
if (pInputStream->usedBits <
(pInputStream->availableBits + syncword_length)
The length of the syncword should subtract from the number of available
bits, not add.
Description: Fixed condition when the end of file was found, unsigned
comparison produced a undesired search. Fixed by casting comparison
if ((Int)pInputStream->usedBits <
((Int)pInputStream->availableBits - syncword_length) )
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Inputs:
pSyncword = Pointer to variable containing the syncword that the
function should be scanning for in the buffer. [ UInt32 * ]
pInputStream = Pointer to a BITS structure, used by the function getbits
to retrieve data from the bitstream. [ BITS * ]
syncword_length = The length of the syncword. [ Int ]
syncword_mask = A mask to be applied to the bitstream before comparison
with the value pointed to by pSyncword. [ UInt32 ]
Local Stores/Buffers/Pointers Needed:
None
Global Stores/Buffers/Pointers Needed:
None
Outputs:
None
Pointers and Buffers Modified:
None
Local Stores Modified:
None
Global Stores Modified:
None
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
This module scans the bitstream for a syncword of any length between 1 and 32.
If certain bits in the syncword are to be ignored, that bit position should
be set to 0 in both parameters *(pSyncword) and syncword_mask. This allows
for a syncword to be constructed out of non-contiguous bits.
Upon finding the syncword's position in the bitstream, a value denoting the
syncword's degree of deviance from being byte-aligned (byte_align_offset)
is set in the structure pointed to by pInputStream.
This is a value between 0 and 7.
If no syncword is found, the function returns status == ERROR.
------------------------------------------------------------------------------
REQUIREMENTS
"Don't care" bits must be set to '0' in both *(pSyncword) and syncword_mask.
This function should not be called if there are less than
(8 + syncword_length) bits in the buffer.
------------------------------------------------------------------------------
REFERENCES
(1) ISO/IEC 13818-7:1997(E)
Part 7
Subpart 6.2 (Audio_Data_Transport_Stream frame, ADTS)
(2) ISO/IEC 11172-3:1993(E)
Part 3
Subpart 2.4.3 The audio decoding process
------------------------------------------------------------------------------
PSEUDO-CODE
IF (pInputStream->usedBits <
(pInputStream->availableBits + syncword_length) )
max_search_length = (pInputStream->availableBits - pInputStream->usedBits);
max_search_length = max_search_length - syncword_length;
search_length = 0;
adts_header =
CALL getbits(syncword_length, pInputStream);
MODIFYING pInputStream->usedBits
RETURNING bits from bitstream of length (syncword_length)
test_for_syncword = adts_header AND syncword_mask;
test_for_syncword = test_for_syncword XOR syncword;
WHILE ( (test_for_syncword != 0) && (search_length > 0) )
search_length = search_length - 1;
adts_header = adts_header << 1;
adts_header = adts_header OR ...
CALL getbits(syncword_length, pInputStream);
MODIFYING pInputStream->usedBits
RETURNING 1 bit from the bitstream
test_for_syncword = adts_header AND syncword_mask;
test_for_syncword = test_for_syncword XOR syncword;
ENDWHILE
IF (search_length == 0)
status = ERROR;
ENDIF
*(pSyncword) = adts_header;
pInputStream->byteAlignOffset =
(pInputStream->usedBits - syncwordlength) AND 0x7;
ELSE
status = ERROR;
ENDIF
return (status);
------------------------------------------------------------------------------
RESOURCES USED
When the code is written for a specific target processor the
the resources used should be documented below.
STACK USAGE: [stack count for this module] + [variable to represent
stack usage for each subroutine called]
where: [stack usage variable] = stack usage for [subroutine
name] (see [filename].ext)
DATA MEMORY USED: x words
PROGRAM MEMORY USED: x words
CLOCK CYCLES: [cycle count equation for this module] + [variable
used to represent cycle count for each subroutine
called]
where: [cycle count variable] = cycle count for [subroutine
name] (see [filename].ext)
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "s_bits.h"
#include "ibstream.h"
#include "find_adts_syncword.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
#define FIND_ADTS_ERROR -1
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
Int find_adts_syncword(
UInt32 *pSyncword,
BITS *pInputStream,
Int syncword_length,
UInt32 syncword_mask)
{
Int status = SUCCESS;
UInt search_length;
UInt32 adts_header = 0;
UInt32 test_for_syncword;
UInt32 syncword = *(pSyncword);
/*
* Determine the maximum number of bits available to this function for
* the syncword search.
*/
if ((Int)pInputStream->usedBits <
((Int)pInputStream->availableBits - syncword_length))
{
search_length = (pInputStream->availableBits - pInputStream->usedBits);
search_length -= syncword_length;
adts_header = getbits(syncword_length, pInputStream);
/*
* Mask the result in adts_header with the syncword_mask, so only the
* bits relevant to syncword detection are compared to *(pSyncword).
*/
test_for_syncword = adts_header & syncword_mask;
test_for_syncword ^= syncword;
/*
* Scan bit-by-bit through the bitstream, until the function either
* runs out of bits, or finds the syncword.
*/
while ((test_for_syncword != 0) && (search_length > 0))
{
search_length--;
adts_header <<= 1;
adts_header |= getbits(1, pInputStream);
test_for_syncword = adts_header & syncword_mask;
test_for_syncword ^= syncword;
}
if (search_length == 0)
{
status = FIND_ADTS_ERROR;
}
/*
* Return the syncword's position in the bitstream. Correct placement
* of the syncword will result in byte_align_offset == 0.
* If the syncword is found not to be byte-aligned, then return
* the degree of disalignment, so further decoding can
* be shifted as necessary.
*
*/
pInputStream->byteAlignOffset =
(pInputStream->usedBits - syncword_length) & 0x7;
} /* END if (pInputStream->usedBits < ...) */
else
{
status = FIND_ADTS_ERROR;
}
*(pSyncword) = adts_header;
return (status);
} /* find_adts_syncword() */

View File

@@ -0,0 +1,87 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./include/find_adts_syncword.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
This function includes the function declaration for find_adts_syncword()
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef FIND_ADTS_SYNCWORD_H
#define FIND_ADTS_SYNCWORD_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "s_bits.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
Int find_adts_syncword(
UInt32 *pSyncword,
BITS *pInputStream,
Int syncword_length,
UInt32 syncword_mask);
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,284 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./src/fwd_long_complex_rot.c
Funtions: fwd_long_complex_rot
------------------------------------------------------------------------------
REVISION HISTORY
Date: 10/18/2002
Description:
(1) Change the input arguments, no shifts information from
long_fft_rx4 is passed, only a single max is passed.
(2) Eliminate search for max, a fixed shift has replaced the
search for max with minimal loss of precision.
(3) Eliminated unused variables
Date: 10/28/2002
Description:
(1) Added comments per code review
(2) Eliminated hardly used condition on if-else (exp==0)
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Inputs:
Data_in = Input vector (sized for long windows
TWICE_FWD_LONG_CX_ROT_LENGTH), with time domain samples
type Int32 *
Data_out = Output vector with a post-rotation by exp(-j(2pi/N)(k+1/8)),
(sized for long windows TWICE_FWD_LONG_CX_ROT_LENGTH)
type Int32 *
max = Input, carries the maximum value of the input vector
"Data_in"
type Int32
Local Stores/Buffers/Pointers Needed:
None
Global Stores/Buffers/Pointers Needed:
None
Outputs:
exp = shift factor to reflect signal scaling
Pointers and Buffers Modified:
Results are return in "Data_out"
Local Stores Modified:
None
Global Stores Modified:
None
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
fwd_long_complex_rot() performs the pre complex rotation for the MDCT
for the case of long windows. It also performs digit reverse ordering of
the first and second halves of the input vector "Data_in", as well as
reordering of the two half vectors (following radix-2 decomposition)
Word normalization is also done to ensure 16 by 16 bit multiplications.
------------------------------------------------------------------------------
REQUIREMENTS
fwd_long_complex_rot() should execute a pre-rotation by
exp(-j(2pi/N)(k+1/8)), digit reverse ordering and normalization
------------------------------------------------------------------------------
REFERENCES
------------------------------------------------------------------------------
RESOURCES USED
When the code is written for a specific target processor the
the resources used should be documented below.
STACK USAGE: [stack count for this module] + [variable to represent
stack usage for each subroutine called]
where: [stack usage variable] = stack usage for [subroutine
name] (see [filename].ext)
DATA MEMORY USED: x words
PROGRAM MEMORY USED: x words
CLOCK CYCLES: [cycle count equation for this module] + [variable
used to represent cycle count for each subroutine
called]
where: [cycle count variable] = cycle count for [subroutine
name] (see [filename].ext)
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "fwd_long_complex_rot.h"
#include "digit_reversal_tables.h"
#include "imdct_fxp.h"
#include "pv_normalize.h"
#include "fxp_mul32.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL VARIABLE DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
Int fwd_long_complex_rot(
Int32 *Data_in,
Int32 *Data_out,
Int32 max)
{
Int i;
const Int32 *p_rotate;
Int32 temp_re;
Int32 temp_im;
Int32 *pData_in_ref1;
Int32 *pData_in_ref2;
Int32 exp_jw;
Int32 temp_re_32;
Int32 temp_im_32;
Int32 *pData_out_1;
Int32 *pData_out_2;
Int32 *pData_out_3;
Int32 *pData_out_4;
Int32 *pData_in_1;
Int32 *pData_in_2;
Int exp;
p_rotate = exp_rotation_N_2048;
pData_in_ref1 = Data_in;
pData_in_ref2 = &Data_in[TWICE_FWD_LONG_CX_ROT_LENGTH];
pData_out_1 = Data_out;
pData_out_2 = &Data_out[LONG_WINDOW_LENGTH_m_1];
pData_out_3 = &Data_out[LONG_WINDOW_LENGTH];
pData_out_4 = &Data_out[TWICE_LONG_WINDOW_LENGTH_m_1];
/*
* Data_out
* >>>> <<<<
* pData_out_3 pData_out_4
* | | | | |
* pData_out_1 pData_out_2
* >>>> <<<<
*/
exp = 16 - pv_normalize(max);
if (exp < 0)
{
exp = 0;
}
/*
* Apply A/2^(diff) + B
*/
pData_in_1 = pData_in_ref1;
pData_in_2 = pData_in_ref2;
for (i = FWD_LONG_CX_ROT_LENGTH; i != 0; i--)
{
/*
* cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
*/
exp_jw = *p_rotate++;
/*
* Use auxiliary variables to avoid double accesses to memory.
* Data in is scaled to use only lower 16 bits.
*/
temp_re = *(pData_in_1++) >> exp;
temp_im = *(pData_in_1++) >> exp;
/*
* Pre-rotation
*/
temp_re_32 = (cmplx_mul32_by_16(temp_re, temp_im, exp_jw));
temp_im_32 = (cmplx_mul32_by_16(temp_im, -temp_re, exp_jw));
*(pData_out_1++) = - temp_re_32;
*(pData_out_2--) = temp_im_32;
*(pData_out_3++) = - temp_im_32;
*(pData_out_4--) = temp_re_32;
/*
* Pointer increment to jump over imag (1 & 4) or real parts
* (2 & 3)
*/
pData_out_1++;
pData_out_2--;
pData_out_3++;
pData_out_4--;
/*
* Repeat procedure for odd index at the output
*/
exp_jw = *p_rotate++;
temp_re = *(pData_in_2++) >> exp;
temp_im = *(pData_in_2++) >> exp;
temp_re_32 = (cmplx_mul32_by_16(temp_re, temp_im, exp_jw));
temp_im_32 = (cmplx_mul32_by_16(temp_im, -temp_re, exp_jw));
*(pData_out_1++) = - temp_re_32;
*(pData_out_2--) = temp_im_32;
*(pData_out_3++) = - temp_im_32;
*(pData_out_4--) = temp_re_32;
pData_out_1++;
pData_out_2--;
pData_out_3++;
pData_out_4--;
}
return (exp + 1);
}

View File

@@ -0,0 +1,96 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./include/fwd_long_complex_rot.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
Header file for functions fwd_long_complex_rot
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef FWD_LONG_COMPLEX_ROT_H
#define FWD_LONG_COMPLEX_ROT_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
#define FWD_LONG_CX_ROT_LENGTH 256
#define TWICE_FWD_LONG_CX_ROT_LENGTH (FWD_LONG_CX_ROT_LENGTH<<1)
#define LONG_WINDOW_LENGTH 1024
#define LONG_WINDOW_LENGTH_m_1 (LONG_WINDOW_LENGTH - 1)
#define TWICE_LONG_WINDOW_LENGTH_m_1 ((LONG_WINDOW_LENGTH<<1) - 1)
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
Int fwd_long_complex_rot(
Int32 *Data_in,
Int32 *Data_out,
Int32 max);
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif /* FWD_LONG_COMPLEX_ROT_H */

View File

@@ -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.
* -------------------------------------------------------------------
*/
/*
Pathname: ./src/fwd_short_complex_rot.c
Funtions: fwd_short_complex_rot
------------------------------------------------------------------------------
REVISION HISTORY
Date: 10/18/2002
Description:
(1) Change the input argument, only a single max is passed.
(2) Eliminate search for max, a fixed shift has replaced the
search for max with minimal loss of precision.
(3) Eliminated unused variables
Date: 10/28/2002
Description:
(1) Added comments per code review
(2) Eliminated hardly used condition on if-else (exp==0)
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Inputs:
Data_in = Input vector (sized for short windows
2*FWD_SHORT_CX_ROT_LENGTH elements), with freq. domain samples
type Int32 *
Data_out = Output vector with a post-rotation by exp(-j(2pi/N)(k+1/8)),
(sized for short windows 2*FWD_SHORT_CX_ROT_LENGTH)
type Int32 *
max = Input, carries the maximum value of the input vector
"Data_in"
type Int32
Local Stores/Buffers/Pointers Needed:
None
Global Stores/Buffers/Pointers Needed:
None
Outputs:
exp = shift factor to reflect signal scaling
Pointers and Buffers Modified:
Results are return in "Data_out"
Local Stores Modified:
None
Global Stores Modified:
None
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
fwd_short_complex_rot() performs the complex rotation for the MDCT
for the case of short windows. It performs digit reverse ordering as well
word normalization to ensure 16 by 16 bit multiplications.
------------------------------------------------------------------------------
REQUIREMENTS
fwd_short_complex_rot() should execute a pre-rotation by
exp(-j(2pi/N)(k+1/8)), digit reverse ordering and word normalization
------------------------------------------------------------------------------
REFERENCES
------------------------------------------------------------------------------
RESOURCES USED
When the code is written for a specific target processor the
the resources used should be documented below.
STACK USAGE: [stack count for this module] + [variable to represent
stack usage for each subroutine called]
where: [stack usage variable] = stack usage for [subroutine
name] (see [filename].ext)
DATA MEMORY USED: x words
PROGRAM MEMORY USED: x words
CLOCK CYCLES: [cycle count equation for this module] + [variable
used to represent cycle count for each subroutine
called]
where: [cycle count variable] = cycle count for [subroutine
name] (see [filename].ext)
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "fwd_short_complex_rot.h"
#include "digit_reversal_tables.h"
#include "imdct_fxp.h"
#include "pv_normalize.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL VARIABLE DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
Int fwd_short_complex_rot(
Int32 *Data_in,
Int32 *Data_out,
Int32 max)
{
Int i;
Int16 I;
const Int16 *pTable;
const Int32 *p_rotate;
Int32 *pData_in_1;
Int exp;
Int32 temp_re;
Int32 temp_im;
Int32 cos_n;
Int32 sin_n;
Int32 temp_re_32;
Int32 temp_im_32;
Int32 *pData_in_ref;
Int32 *pData_out_1;
Int32 *pData_out_2;
Int32 *pData_out_3;
Int32 *pData_out_4;
pTable = digit_reverse_64;
p_rotate = exp_rotation_N_256;
pData_in_ref = Data_in;
exp = 16 - pv_normalize(max);
if (exp < 0)
{
exp = 0;
}
pData_out_1 = Data_out;
pData_out_2 = &Data_out[TWICE_FWD_SHORT_CX_ROT_LENGTH_m_1];
pData_out_3 = &Data_out[TWICE_FWD_SHORT_CX_ROT_LENGTH];
pData_out_4 = &Data_out[FOUR_FWD_SHORT_CX_ROT_LENGTH_m_1];
/*
* Data_out
* >>>> <<<<
* pData_out_3 pData_out_4
* | | | | |
* pData_out_1 pData_out_2
* >>>> <<<<
*/
for (i = FWD_SHORT_CX_ROT_LENGTH; i != 0; i--)
{
/*
* Perform digit reversal by accessing index I from table
*/
I = *pTable++;
pData_in_1 = pData_in_ref + I;
/*
* cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
*/
sin_n = *p_rotate++;
cos_n = sin_n >> 16;
sin_n = sin_n & 0xFFFF;
/*
* Use auxiliary variables to avoid double accesses to memory.
* Data in is scaled to use only lower 16 bits.
*/
temp_re = *(pData_in_1++) >> exp;
temp_im = *(pData_in_1) >> exp;
/*
* Pre-rotation
*/
temp_re_32 = (temp_re * cos_n + temp_im * sin_n) >> 16;
temp_im_32 = (temp_im * cos_n - temp_re * sin_n) >> 16;
*(pData_out_1++) = - temp_re_32;
*(pData_out_2--) = temp_im_32;
*(pData_out_3++) = - temp_im_32;
*(pData_out_4--) = temp_re_32;
/*
* Pointer increment to jump over imag (1 & 4) or real parts
* (2 & 3)
*/
pData_out_1++;
pData_out_2--;
pData_out_3++;
pData_out_4--;
} /* for(i) */
return (exp);
}

View File

@@ -0,0 +1,92 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: .fwd_short_complex_rot.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
Header file for functions fwd_short_complex_rot
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef FWD_SHORT_COMPLEX_ROT_H
#define FWD_SHORT_COMPLEX_ROT_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
#define FWD_SHORT_CX_ROT_LENGTH 64
#define TWICE_FWD_SHORT_CX_ROT_LENGTH (FWD_SHORT_CX_ROT_LENGTH<<1)
#define TWICE_FWD_SHORT_CX_ROT_LENGTH_m_1 ((FWD_SHORT_CX_ROT_LENGTH<<1) - 1)
#define FOUR_FWD_SHORT_CX_ROT_LENGTH_m_1 ((FWD_SHORT_CX_ROT_LENGTH<<2) - 1)
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
Int fwd_short_complex_rot(
Int32 *Data_in,
Int32 *Data_out,
Int32 max);
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif /* FWD_SHORT_COMPLEX_ROT_H */

View File

@@ -0,0 +1,72 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./c/include/fxp_mul32.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
------------------------------------------------------------------------------
*/
#ifndef FXP_MUL32
#define FXP_MUL32
#if defined(PV_ARM_V5)
#include "fxp_mul32_arm_v5.h"
#elif defined(PV_ARM_V4)
#include "fxp_mul32_arm_v4.h"
#elif defined(PV_ARM_MSC_EVC_V4)
#include "fxp_mul32_c_msc_evc.h"
#elif defined(PV_ARM_MSC_EVC_V5)
#include "fxp_mul32_c_msc_evc_armv5.h"
#elif defined(PV_ARM_GCC_V5)
#include "fxp_mul32_arm_gcc.h"
#elif defined(PV_ARM_GCC_V4)
#include "fxp_mul32_arm_v4_gcc.h"
#else
#ifndef C_EQUIVALENT
#define C_EQUIVALENT
#endif
#include "fxp_mul32_c_equivalent.h"
#endif
#endif /* FXP_MUL32 */

View File

@@ -0,0 +1,547 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./c/include/fxp_mul32_arm_gcc.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
------------------------------------------------------------------------------
*/
#ifndef FXP_MUL32_ARM_GCC
#define FXP_MUL32_ARM_GCC
#ifdef __cplusplus
extern "C"
{
#endif
#include "pv_audio_type_defs.h"
#if (defined (PV_ARM_GCC_V4) || defined(PV_ARM_GCC_V5)) /* ARM GNU COMPILER */
#define preload_cache( a)
static inline Int32 shft_lft_1(Int32 y)
{
register Int32 x;
register Int32 ra = y;
asm volatile(
"qadd %0, %1, %1\n\t"
: "=&r*i"(x)
: "r"(ra));
return (x);
}
static inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, const Int32 L_var2)
{
register Int32 tmp;
register Int32 ra = (Int32)L_var1;
register Int32 rb = (Int32)L_var2;
asm volatile(
"smulbb %0, %1, %2"
: "=&r*i"(tmp)
: "r"(ra),
"r"(rb));
return (tmp);
}
#define fxp_mul_16_by_16(a, b) fxp_mul_16_by_16bb( a, b)
static inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, const Int32 L_var2)
{
register Int32 tmp;
register Int32 ra = (Int32)L_var1;
register Int32 rb = (Int32)L_var2;
asm volatile(
"smultb %0, %1, %2"
: "=&r*i"(tmp)
: "r"(ra),
"r"(rb));
return (tmp);
}
static inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, const Int32 L_var2)
{
register Int32 tmp;
register Int32 ra = (Int32)L_var1;
register Int32 rb = (Int32)L_var2;
asm volatile(
"smulbt %0, %1, %2"
: "=&r*i"(tmp)
: "r"(ra),
"r"(rb));
return (tmp);
}
static inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, const Int32 L_var2)
{
register Int32 tmp;
register Int32 ra = (Int32)L_var1;
register Int32 rb = (Int32)L_var2;
asm volatile(
"smultt %0, %1, %2"
: "=&r*i"(tmp)
: "r"(ra),
"r"(rb));
return (tmp);
}
static inline Int32 fxp_mac_16_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
{
register Int32 tmp;
register Int32 ra = (Int32)L_var1;
register Int32 rb = (Int32)L_var2;
register Int32 rc = (Int32)L_add;
asm volatile(
"smlabb %0, %1, %2, %3"
: "=&r*i"(tmp)
: "r"(ra),
"r"(rb),
"r"(rc));
return (tmp);
}
static inline Int32 fxp_mac_16_by_16_bb(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
{
register Int32 tmp;
register Int32 ra = (Int32)L_var1;
register Int32 rb = (Int32)L_var2;
register Int32 rc = (Int32)L_add;
asm volatile(
"smlabb %0, %1, %2, %3"
: "=&r*i"(tmp)
: "r"(ra),
"r"(rb),
"r"(rc));
return (tmp);
}
static inline Int32 fxp_mac_16_by_16_bt(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
{
register Int32 tmp;
register Int32 ra = (Int32)L_var1;
register Int32 rb = (Int32)L_var2;
register Int32 rc = (Int32)L_add;
asm volatile(
"smlabt %0, %1, %2, %3"
: "=&r*i"(tmp)
: "r"(ra),
"r"(rb),
"r"(rc));
return (tmp);
}
static inline Int32 cmplx_mul32_by_16(Int32 x, const Int32 y, Int32 exp_jw)
{
register Int32 cx_sum;
register Int32 rx = (Int32)x;
register Int32 ry = (Int32)y;
register Int32 rexp = (Int32)exp_jw;
asm volatile(
"smulwt %0, %1, %3\n\t"
"smlawb %0, %2, %3, %0"
: "=&r*i"(cx_sum)
: "r"(rx),
"r"(ry),
"r"(rexp));
return (cx_sum);
}
static inline Int32 fxp_mul32_by_16(Int32 L_var1, const Int32 L_var2)
{
register Int32 tmp;
register Int32 ra = (Int32)L_var1;
register Int32 rb = (Int32)L_var2;
asm volatile(
"smulwb %0, %1, %2"
: "=&r*i"(tmp)
: "r"(ra),
"r"(rb));
return (tmp);
}
#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16( a, b)
static inline Int32 fxp_mul32_by_16t(Int32 L_var1, const Int32 L_var2)
{
register Int32 tmp;
register Int32 ra = (Int32)L_var1;
register Int32 rb = (Int32)L_var2;
asm volatile(
"smulwt %0, %1, %2"
: "=&r*i"(tmp)
: "r"(ra),
"r"(rb));
return (tmp);
}
static inline Int32 fxp_mac32_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
{
register Int32 tmp;
register Int32 ra = (Int32)L_var1;
register Int32 rb = (Int32)L_var2;
register Int32 rc = (Int32)L_add;
asm volatile(
"smlawb %0, %1, %2, %3"
: "=&r*i"(tmp)
: "r"(ra),
"r"(rb),
"r"(rc));
return (tmp);
}
__inline int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2)
{
sum += (int64)L_var1 * L_var2;
return (sum);
}
static inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
register Int32 rc = (Int32)L_add;
asm volatile("smull %1, %0, %2, %3\n\t"
"add %4, %4, %0, asl #2\n\t"
"add %0, %4, %1, lsr #30"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb),
"r"(rc));
return (result64_hi);
}
static inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
register Int32 rc = (Int32)L_add;
asm volatile("smull %1, %0, %2, %3\n\t"
"add %0, %0, %4"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb),
"r"(rc));
return (result64_hi);
}
static inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
register Int32 rc = (Int32)L_sub;
asm volatile("smull %1, %0, %2, %3\n\t"
"sub %0, %4, %0"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb),
"r"(rc));
return (result64_hi);
}
static inline Int32 fxp_mul32_Q31(const Int32 a, const Int32 b)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
asm volatile(
"smull %1, %0, %2, %3"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb));
return (result64_hi);
}
static inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
asm volatile("smull %1, %0, %2, %3\n\t"
"mov %0, %0, lsl #2\n\t"
"orr %0, %0, %1, lsr #30"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb));
return (result64_hi);
}
static inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
register Int32 rc = (Int32)L_add;
asm volatile("smull %1, %0, %2, %3\n\t"
"add %4, %4, %0, lsl #3\n\t"
"add %0, %4, %1, lsr #29"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb),
"r"(rc));
return (result64_hi);
}
static inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
register Int32 rc = (Int32)L_sub;
asm volatile("smull %1, %0, %2, %3\n\t"
"sub %4, %4, %0, lsl #3\n\t"
"sub %0, %4, %1, lsr #29"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb),
"r"(rc));
return (result64_hi);
}
static inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
asm volatile("smull %1, %0, %2, %3\n\t"
"mov %0, %0, lsl #3\n\t"
"orr %0, %0, %1, lsr #29"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb));
return (result64_hi);
}
static inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
asm volatile("smull %1, %0, %2, %3\n\t"
"mov %0, %0, lsl #4\n\t"
"orr %0, %0, %1, lsr #28"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb));
return (result64_hi);
}
static inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
asm volatile("smull %1, %0, %2, %3\n\t"
"mov %0, %0, lsl #5\n\t"
"orr %0, %0, %1, lsr #27"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb));
return (result64_hi);
}
static inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
asm volatile("smull %1, %0, %2, %3\n\t"
"mov %0, %0, lsl #6\n\t"
"orr %0, %0, %1, lsr #26"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb));
return (result64_hi);
}
static inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
asm volatile("smull %1, %0, %2, %3\n\t"
"mov %0, %0, lsl #12\n\t"
"orr %0, %0, %1, lsr #20"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb));
return (result64_hi);
}
static inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
asm volatile("smull %1, %0, %2, %3\n\t"
"mov %0, %0, lsl #17\n\t"
"orr %0, %0, %1, lsr #15"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb));
return (result64_hi);
}
static inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
asm volatile("smull %1, %0, %2, %3\n\t"
"mov %0, %0, lsl #18\n\t"
"orr %0, %0, %1, lsr #14"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb));
return (result64_hi);
}
#endif
#ifdef __cplusplus
}
#endif
#endif /* FXP_MUL32 */

View File

@@ -0,0 +1,429 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: fxp_mul32_c_equivalent.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
------------------------------------------------------------------------------
*/
#ifndef FXP_MUL32_ARM_V4
#define FXP_MUL32_ARM_V4
#ifdef __cplusplus
extern "C"
{
#endif
#include "pv_audio_type_defs.h"
#if defined(PV_ARM_V4)
#define preload_cache( a)
__inline Int32 shft_lft_1(Int32 L_var1)
{
Int32 x;
Int32 z = 1; /* rvct compiler problem */
__asm
{
mov x, L_var1, asl 1
teq L_var1, x, asr z
eorne x, INT32_MAX, L_var1, asr #31
}
return(x);
}
__inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, Int32 L_var2)
{
__asm
{
mov L_var2, L_var2, asl #16
mov L_var2, L_var2, asr #16
mov L_var1, L_var1, asl #16
mov L_var1, L_var1, asr #16
mul L_var1, L_var2, L_var1
}
return L_var1;
}
#define fxp_mul_16_by_16(a, b) fxp_mul_16_by_16bb( a, b)
__inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, Int32 L_var2)
{
__asm
{
mov L_var2, L_var2, asl #16
mov L_var2, L_var2, asr #16
mov L_var1, L_var1, asr #16
mul L_var1, L_var2, L_var1
}
return L_var1;
}
__inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, Int32 L_var2)
{
__asm
{
mov L_var2, L_var2, asr #16
mov L_var1, L_var1, asl #16
mov L_var1, L_var1, asr #16
mul L_var1, L_var2, L_var1
}
return L_var1;
}
__inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, Int32 L_var2)
{
__asm
{
mov L_var2, L_var2, asr #16
mov L_var1, L_var1, asr #16
mul L_var1, L_var2, L_var1
}
return L_var1;
}
__inline Int32 fxp_mac_16_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
{
__asm
{
mla L_add, L_var1, L_var2, L_add
}
return (L_add);
}
__inline Int32 fxp_mac_16_by_16_bb(const Int32 L_var1, Int32 L_var2, Int32 L_add)
{
__asm
{
mov L_var2, L_var2, asl #16
mov L_var2, L_var2, asr #16
mla L_add, L_var1, L_var2, L_add
}
return L_add;
}
__inline Int32 fxp_mac_16_by_16_bt(Int16 L_var1, Int32 L_var2, Int32 L_add)
{
__asm
{
mov L_var2, L_var2, asr #16
mla L_add, L_var1, L_var2, L_add
}
return L_add;
}
__inline Int32 cmplx_mul32_by_16(Int32 x, const Int32 y, Int32 exp_jw)
{
Int32 result64_hi;
Int32 rTmp0;
Int32 iTmp0;
__asm
{
mov rTmp0, exp_jw, asr #16
mov rTmp0, rTmp0, asl #16
mov iTmp0, exp_jw, asl #16
smull rTmp0, result64_hi, x, rTmp0
smlal iTmp0, result64_hi, y, iTmp0
}
return (result64_hi);
}
__inline Int32 fxp_mul32_by_16(Int32 L_var1, Int32 L_var2)
{
Int32 result64_hi;
__asm
{
mov L_var2, L_var2, asl #16
smull L_var1, result64_hi, L_var2, L_var1
}
return (result64_hi);
}
#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16( a, b)
__inline Int32 fxp_mul32_by_16t(Int32 L_var1, Int32 L_var2)
{
Int32 result64_hi;
__asm
{
mov L_var2, L_var2, asr #16
mov L_var2, L_var2, asl #16
smull L_var1, result64_hi, L_var2, L_var1
}
return (result64_hi);
}
__inline Int32 fxp_mac32_by_16(Int32 L_var1, Int32 L_var2, Int32 L_add)
{
__asm
{
mov L_var2, L_var2, asl #16
smlal L_var1, L_add, L_var2, L_var1
}
return (L_add);
}
__inline int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2)
{
uint32 b = (UInt32)(sum);
int32 c = Int32(sum >> 32);
__asm
{
smlal b, c, L_var1, L_var2
}
return (((int64(c)) << 32) | b);
}
__inline Int32 fxp_mul32_Q31(Int32 L_var1, const Int32 L_var2)
{
Int32 result64_hi;
__asm
{
smull L_var1, result64_hi, L_var2, L_var1
}
return (result64_hi);
}
__inline Int32 fxp_mac32_Q31(Int32 L_add, Int32 L_var1, const Int32 L_var2)
{
__asm
{
smlal L_var1, L_add, L_var2, L_var1
}
return L_add;
}
__inline Int32 fxp_msu32_Q31(Int32 L_sub, Int32 L_var1, const Int32 L_var2)
{
__asm
{
rsb L_var1, L_var1, #0
smlal L_var1, L_sub, L_var2, L_var1
}
return L_sub;
}
__inline Int32 fxp_mul32_Q30(const Int32 L_var1, const Int32 L_var2)
{
Int32 result64_hi;
Int32 result64_lo;
__asm
{
smull result64_lo, result64_hi, L_var2, L_var1
mov result64_hi, result64_hi, asl #2
orr result64_hi, result64_hi, result64_lo, lsr #30
}
return (result64_hi);
}
__inline Int32 fxp_mac32_Q30(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
{
Int32 result64_hi;
Int32 result64_lo;
__asm
{
smull result64_lo, result64_hi, L_var2, L_var1
add L_add, L_add, result64_hi, asl #2
add L_add, L_add, result64_lo, lsr #30
}
return (L_add);
}
__inline Int32 fxp_mul32_Q29(const Int32 L_var1, const Int32 L_var2)
{
Int32 result64_hi;
Int32 result64_lo;
__asm
{
smull result64_lo, result64_hi, L_var2, L_var1
mov result64_hi, result64_hi, asl #3
orr result64_hi, result64_hi, result64_lo, lsr #29
}
return (result64_hi);
}
__inline Int32 fxp_mac32_Q29(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
{
Int32 result64_hi;
Int32 result64_lo;
__asm
{
smull result64_lo, result64_hi, L_var2, L_var1
add L_add, L_add, result64_hi, asl #3
add L_add, L_add, result64_lo, lsr #29
}
return (L_add);
}
__inline Int32 fxp_msu32_Q29(const Int32 L_var1, const Int32 L_var2, Int32 L_sub)
{
Int32 result64_hi;
Int32 result64_lo;
__asm
{
smull result64_lo, result64_hi, L_var2, L_var1
sub L_sub, L_sub, result64_hi, asl #3
sub L_sub, L_sub, result64_lo, lsr #29
}
return (L_sub);
}
__inline Int32 fxp_mul32_Q28(const Int32 L_var1, const Int32 L_var2)
{
Int32 result64_hi;
Int32 result64_lo;
__asm
{
smull result64_lo, result64_hi, L_var2, L_var1
mov result64_hi, result64_hi, asl #4
orr result64_hi, result64_hi, result64_lo, lsr #28
}
return (result64_hi);
}
__inline Int32 fxp_mul32_Q27(const Int32 L_var1, const Int32 L_var2)
{
Int32 result64_hi;
Int32 result64_lo;
__asm
{
smull result64_lo, result64_hi, L_var2, L_var1
mov result64_hi, result64_hi, asl #5
orr result64_hi, result64_hi, result64_lo, lsr #27
}
return (result64_hi);
}
__inline Int32 fxp_mul32_Q26(const Int32 L_var1, const Int32 L_var2)
{
Int32 result64_hi;
Int32 result64_lo;
__asm
{
smull result64_lo, result64_hi, L_var2, L_var1
mov result64_hi, result64_hi, asl #6
orr result64_hi, result64_hi, result64_lo, lsr #26
}
return (result64_hi);
}
__inline Int32 fxp_mul32_Q20(const Int32 L_var1, const Int32 L_var2)
{
Int32 result64_hi;
Int32 result64_lo;
__asm
{
smull result64_lo, result64_hi, L_var2, L_var1
mov result64_hi, result64_hi, asl #12
orr result64_hi, result64_hi, result64_lo, lsr #20
}
return (result64_hi);
}
__inline Int32 fxp_mul32_Q15(const Int32 L_var1, const Int32 L_var2)
{
Int32 result64_hi;
Int32 result64_lo;
__asm
{
smull result64_lo, result64_hi, L_var2, L_var1
mov result64_hi, result64_hi, asl #17
orr result64_hi, result64_hi, result64_lo, lsr #15
}
return (result64_hi);
}
__inline Int32 fxp_mul32_Q14(const Int32 L_var1, const Int32 L_var2)
{
Int32 result64_hi;
Int32 result64_lo;
__asm
{
smull result64_lo, result64_hi, L_var2, L_var1
mov result64_hi, result64_hi, asl #18
orr result64_hi, result64_hi, result64_lo, lsr #14
}
return (result64_hi);
}
#endif
#ifdef __cplusplus
}
#endif
#endif /* FXP_MUL32 */

View File

@@ -0,0 +1,630 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: fxp_mul32_arm_v4_gcc.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
------------------------------------------------------------------------------
*/
#ifndef FXP_MUL32_V4_ARM_GCC
#define FXP_MUL32_V4_ARM_GCC
#ifdef __cplusplus
extern "C"
{
#endif
#include "pv_audio_type_defs.h"
#if defined (_ARM_V4_GCC) /* ARM_V4 GNU COMPILER */
#define preload_cache( a)
static inline Int32 shft_lft_1(Int32 L_var1)
{
Int32 x;
register Int32 ra = L_var1;
Int32 z = INT32_MAX;
asm volatile(
"mov %0, %1, asl #1\n\t"
"teq %1, %0, asr #1\n\t"
"eorne %0, %2, %1, asr #31"
: "=&r*i"(x)
: "r"(ra),
"r"(z));
return(x);
}
static inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, Int32 L_var2)
{
Int32 tmp1;
Int32 tmp2;
register Int32 ra = (Int32)L_var1;
register Int32 rb = (Int32)L_var2;
asm volatile(
"mov %0, %3, asl #16\n\t"
"mov %0, %0, asr #16\n\t"
"mov %1, %2, asl #16\n\t"
"mov %1, %1, asr #16\n\t"
"mul %0, %1, %0"
: "=&r*i"(tmp1),
"=&r*i"(tmp2)
: "r"(ra),
"r"(rb));
return (tmp1);
}
#define fxp_mul_16_by_16(a, b) fxp_mul_16_by_16bb( a, b)
static inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, Int32 L_var2)
{
Int32 tmp1;
Int32 tmp2;
register Int32 ra = (Int32)L_var1;
register Int32 rb = (Int32)L_var2;
asm volatile(
"mov %0, %3, asl #16\n\t"
"mov %0, %0, asr #16\n\t"
"mov %1, %2, asr #16\n\t"
"mul %0, %1, %0"
: "=&r*i"(tmp1),
"=&r*i"(tmp2)
: "r"(ra),
"r"(rb));
return (tmp1);
}
static inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, Int32 L_var2)
{
Int32 tmp1;
Int32 tmp2;
register Int32 ra = (Int32)L_var1;
register Int32 rb = (Int32)L_var2;
asm volatile(
"mov %0, %3, asr #16\n\t"
"mov %1, %2, asl #16\n\t"
"mov %1, %1, asr #16\n\t"
"mul %0, %1, %0"
: "=&r*i"(tmp1),
"=&r*i"(tmp2)
: "r"(ra),
"r"(rb));
return (tmp1);
}
static inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, Int32 L_var2)
{
Int32 tmp1;
Int32 tmp2;
register Int32 ra = (Int32)L_var1;
register Int32 rb = (Int32)L_var2;
asm volatile(
"mov %0, %3, asr #16\n\t"
"mov %1, %2, asr #16\n\t"
"mul %0, %1, %0"
: "=&r*i"(tmp1),
"=&r*i"(tmp2)
: "r"(ra),
"r"(rb));
return (tmp1);
}
static inline Int32 fxp_mac_16_by_16(Int16 L_var1, Int16 L_var2, Int32 L_add)
{
Int32 tmp;
register Int32 ra = (Int32)L_var1;
register Int32 rb = (Int32)L_var2;
register Int32 rc = (Int32)L_add;
asm volatile(
"mla %0, %1, %2, %3"
: "=&r*i"(tmp)
: "r"(ra),
"r"(rb),
"r"(rc));
return (tmp);
}
static inline Int32 fxp_mac_16_by_16_bb(Int16 L_var1, Int32 L_var2, Int32 L_add)
{
Int32 tmp1;
Int32 tmp2;
register Int32 ra = (Int32)L_var1;
register Int32 rb = (Int32)L_var2;
register Int32 rc = (Int32)L_add;
asm volatile(
"mov %0, %3, asl #16\n\t"
"mov %0, %0, asr #16\n\t"
"mla %1, %0, %2, %4"
: "=&r*i"(tmp1),
"=&r*i"(tmp2)
: "r"(ra),
"r"(rb),
"r"(rc));
return (tmp2);
}
static inline Int32 fxp_mac_16_by_16_bt(Int16 L_var1, Int32 L_var2, Int32 L_add)
{
Int32 tmp1;
Int32 tmp2;
register Int32 ra = (Int32)L_var1;
register Int32 rb = (Int32)L_var2;
register Int32 rc = (Int32)L_add;
asm volatile(
"mov %0, %3, asr #16\n\t"
"mla %1, %0, %2, %4"
: "=&r*i"(tmp1),
"=&r*i"(tmp2)
: "r"(ra),
"r"(rb),
"r"(rc));
return (tmp2);
}
static inline Int32 cmplx_mul32_by_16(Int32 x, Int32 y, Int32 exp_jw)
{
Int32 rTmp0;
Int32 iTmp0;
Int32 result64_hi;
register Int32 ra = (Int32)x;
register Int32 rb = (Int32)y;
register Int32 rc = (Int32)exp_jw;
asm volatile(
"mov %0, %5, asr #16\n\t"
"mov %1, %5, asl #16\n\t"
"mov %0, %0, asl #16\n\t"
: "=&r*i"(rTmp0),
"=&r*i"(iTmp0),
"=&r*i"(result64_hi)
: "r"(ra),
"r"(rb),
"r"(rc));
asm volatile(
"smull %0, %2, %3, %0\n\t"
"smlal %1, %2, %4, %1"
: "=&r*i"(rTmp0),
"=&r*i"(iTmp0),
"=&r*i"(result64_hi)
: "r"(ra),
"r"(rb),
"r"(rc));
return (result64_hi);
}
static inline Int32 fxp_mul32_by_16(Int32 L_var1, Int32 L_var2)
{
Int32 rTmp0;
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)L_var1;
register Int32 rb = (Int32)L_var2;
asm volatile(
"mov %0, %4, asl #16\n\t"
"smull %2, %1, %0, %3"
: "=&r*i"(rTmp0),
"=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb));
return (result64_hi);
}
#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16( a, b)
static inline Int32 fxp_mul32_by_16t(Int32 L_var1, Int32 L_var2)
{
Int32 rTmp0;
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)L_var1;
register Int32 rb = (Int32)L_var2;
asm volatile(
"mov %0, %4, asr #16\n\t"
"mov %0, %0, asl #16\n\t"
"smull %2, %1, %0, %3"
: "=&r*i"(rTmp0),
"=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb));
return (result64_hi);
}
static inline Int32 fxp_mac32_by_16(Int32 L_var1, Int32 L_var2, Int32 L_add)
{
Int32 rTmp0;
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)L_var1;
register Int32 rb = (Int32)L_var2;
register Int32 rc = (Int32)L_add;
asm volatile(
"mov %0, %4, asl #16\n\t"
"mov %1, %5\n\t"
"smlal %2, %1, %0, %3"
: "=&r*i"(rTmp0),
"=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb),
"r"(rc));
return (result64_hi);
}
static inline int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2)
{
sum += (int64)L_var1 * L_var2;
return (sum);
}
static inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
register Int32 rc = (Int32)L_add;
asm volatile("smull %1, %0, %2, %3\n\t"
"add %4, %4, %0, asl #2\n\t"
"add %0, %4, %1, lsr #30"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb),
"r"(rc));
return (result64_hi);
}
static inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
register Int32 rc = (Int32)L_add;
asm volatile("smull %1, %0, %2, %3\n\t"
"add %0, %0, %4"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb),
"r"(rc));
return (result64_hi);
}
static inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
register Int32 rc = (Int32)L_sub;
asm volatile("smull %1, %0, %2, %3\n\t"
"sub %0, %4, %0"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb),
"r"(rc));
return (result64_hi);
}
static inline Int32 fxp_mul32_Q31(const Int32 a, const Int32 b)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
asm volatile(
"smull %1, %0, %2, %3"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb));
return (result64_hi);
}
static inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
asm volatile("smull %1, %0, %2, %3\n\t"
"mov %0, %0, lsl #2\n\t"
"orr %0, %0, %1, lsr #30"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb));
return (result64_hi);
}
static inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
register Int32 rc = (Int32)L_add;
asm volatile("smull %1, %0, %2, %3\n\t"
"add %4, %4, %0, lsl #3\n\t"
"add %0, %4, %1, lsr #29"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb),
"r"(rc));
return (result64_hi);
}
static inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
register Int32 rc = (Int32)L_sub;
asm volatile("smull %1, %0, %2, %3\n\t"
"sub %4, %4, %0, lsl #3\n\t"
"sub %0, %4, %1, lsr #29"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb),
"r"(rc));
return (result64_hi);
}
static inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
asm volatile("smull %1, %0, %2, %3\n\t"
"mov %0, %0, lsl #3\n\t"
"orr %0, %0, %1, lsr #29"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb));
return (result64_hi);
}
static inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
asm volatile("smull %1, %0, %2, %3\n\t"
"mov %0, %0, lsl #4\n\t"
"orr %0, %0, %1, lsr #28"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb));
return (result64_hi);
}
static inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
asm volatile("smull %1, %0, %2, %3\n\t"
"mov %0, %0, lsl #5\n\t"
"orr %0, %0, %1, lsr #27"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb));
return (result64_hi);
}
static inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
asm volatile("smull %1, %0, %2, %3\n\t"
"mov %0, %0, lsl #6\n\t"
"orr %0, %0, %1, lsr #26"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb));
return (result64_hi);
}
static inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
asm volatile("smull %1, %0, %2, %3\n\t"
"mov %0, %0, lsl #12\n\t"
"orr %0, %0, %1, lsr #20"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb));
return (result64_hi);
}
static inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
asm volatile("smull %1, %0, %2, %3\n\t"
"mov %0, %0, lsl #17\n\t"
"orr %0, %0, %1, lsr #15"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb));
return (result64_hi);
}
static inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b)
{
Int32 result64_hi;
Int32 result64_lo;
register Int32 ra = (Int32)a;
register Int32 rb = (Int32)b;
asm volatile("smull %1, %0, %2, %3\n\t"
"mov %0, %0, lsl #18\n\t"
"orr %0, %0, %1, lsr #14"
: "=&r*i"(result64_hi),
"=&r*i"(result64_lo)
: "r"(ra),
"r"(rb));
return (result64_hi);
}
#endif
#ifdef __cplusplus
}
#endif
#endif /* FXP_MUL32_V4_ARM_GCC */

View File

@@ -0,0 +1,450 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./c/include/fxp_mul32_arm_v5.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
------------------------------------------------------------------------------
*/
#ifndef FXP_MUL32_ARM_V5
#define FXP_MUL32_ARM_V5
#ifdef __cplusplus
extern "C"
{
#endif
#include "pv_audio_type_defs.h"
#if defined(PV_ARM_V5)
//#undef EXTENDED_ASM
#define EXTENDED_ASM
#define _ARM_V5_
__inline Int32 shft_lft_1(Int32 L_var1)
{
__asm
{
qadd L_var1, L_var1, L_var1
}
return L_var1;
}
__inline Int32 fxp_mul_16_by_16(Int32 L_var1, Int32 L_var2)
{
__asm
{
smulbb L_var1, L_var1, L_var2
}
return L_var1;
}
__inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, Int32 L_var2)
{
__asm
{
smulbb L_var1, L_var1, L_var2
}
return L_var1;
}
__inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, Int32 L_var2)
{
__asm
{
smultb L_var1, L_var1, L_var2
}
return L_var1;
}
__inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, Int32 L_var2)
{
__asm
{
smultt L_var1, L_var1, L_var2
}
return L_var1;
}
__inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, Int32 L_var2)
{
__asm
{
smulbt L_var1, L_var1, L_var2
}
return L_var1;
}
__inline Int32 fxp_mac_16_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
{
__asm
{
smlabb L_add, L_var1, L_var2, L_add
}
return (L_add);
}
__inline Int32 fxp_mac_16_by_16_bb(const Int32 L_var1, Int32 L_var2, Int32 L_add)
{
__asm
{
smlabb L_add, L_var1, L_var2, L_add
}
return L_add;
}
__inline Int32 fxp_mac_16_by_16_bt(const Int32 L_var1, Int32 L_var2, Int32 L_add)
{
__asm
{
smlabt L_add, L_var1, L_var2, L_add
}
return L_add;
}
__inline Int32 fxp_mac_16_by_16_tb(const Int32 L_var1, Int32 L_var2, Int32 L_add)
{
__asm
{
smlatb L_add, L_var1, L_var2, L_add
}
return L_add;
}
__inline Int32 fxp_mac_16_by_16_tt(const Int32 L_var1, Int32 L_var2, Int32 L_add)
{
__asm
{
smlatt L_add, L_var1, L_var2, L_add
}
return L_add;
}
__inline Int32 fxp_mac32_by_16(Int32 L_var1, const Int32 L_var2, Int32 L_add)
{
__asm
{
smlawb L_add, L_var1, L_var2, L_add
}
return (L_add);
}
__inline int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2)
{
uint32 b = (UInt32)(sum);
int32 c = Int32(sum >> 32);
__asm
{
smlal b, c, L_var1, L_var2
}
return (((int64(c)) << 32) | b);
}
__inline Int32 fxp_mac32_Q31(Int32 L_add, Int32 L_var1, const Int32 L_var2)
{
__asm
{
smlal L_var1, L_add, L_var2, L_var1
}
return L_add;
}
__inline Int32 fxp_msu32_Q31(Int32 L_sub, Int32 L_var1, const Int32 L_var2)
{
__asm
{
rsb L_var1, L_var1, #0
smlal L_var1, L_sub, L_var2, L_var1
}
return L_sub;
}
__inline Int32 fxp_mul32_Q31(Int32 L_var1, const Int32 L_var2)
{
Int32 result64_hi;
__asm
{
smull L_var1, result64_hi, L_var2, L_var1
}
return (result64_hi);
}
__inline Int32 fxp_mul32_Q30(const Int32 L_var1, const Int32 L_var2)
{
Int32 result64_hi;
Int32 result64_lo;
__asm
{
smull result64_lo, result64_hi, L_var2, L_var1
mov result64_hi, result64_hi, asl #2
#ifdef EXTENDED_ASM
mov result64_lo, result64_lo, lsr #30
orr result64_hi, result64_lo, result64_hi
#else
orr result64_hi, result64_hi, result64_lo, lsr #30
#endif
}
return (result64_hi);
}
__inline Int32 fxp_mac32_Q30(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
{
Int32 result64_hi;
Int32 result64_lo;
__asm
{
smull result64_lo, result64_hi, L_var2, L_var1
add L_add, L_add, result64_hi, asl #2
add L_add, L_add, result64_lo, lsr #30
}
return (L_add);
}
__inline Int32 fxp_mul32_Q29(const Int32 L_var1, const Int32 L_var2)
{
Int32 result64_hi;
Int32 result64_lo;
__asm
{
smull result64_lo, result64_hi, L_var2, L_var1
mov result64_hi, result64_hi, asl #3
#ifdef EXTENDED_ASM
mov result64_lo, result64_lo, lsr #29
orr result64_hi, result64_lo, result64_hi
#else
orr result64_hi, result64_hi, result64_lo, lsr #29
#endif
}
return (result64_hi);
}
__inline Int32 fxp_mac32_Q29(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
{
Int32 result64_hi;
Int32 result64_lo;
__asm
{
smull result64_lo, result64_hi, L_var2, L_var1
add L_add, L_add, result64_hi, asl #3
add L_add, L_add, result64_lo, lsr #29
}
return (L_add);
}
__inline Int32 fxp_msu32_Q29(const Int32 L_var1, const Int32 L_var2, Int32 L_sub)
{
Int32 result64_hi;
Int32 result64_lo;
__asm
{
smull result64_lo, result64_hi, L_var2, L_var1
sub L_sub, L_sub, result64_hi, asl #3
sub L_sub, L_sub, result64_lo, lsr #29
}
return (L_sub);
}
__inline Int32 fxp_mul32_Q28(const Int32 L_var1, const Int32 L_var2)
{
Int32 result64_hi;
Int32 result64_lo;
__asm
{
smull result64_lo, result64_hi, L_var2, L_var1
mov result64_hi, result64_hi, asl #4
#ifdef EXTENDED_ASM
mov result64_lo, result64_lo, lsr #28
orr result64_hi, result64_lo, result64_hi
#else
orr result64_hi, result64_hi, result64_lo, lsr #28
#endif
}
return (result64_hi);
}
__inline Int32 fxp_mul32_Q27(const Int32 L_var1, const Int32 L_var2)
{
Int32 result64_hi;
Int32 result64_lo;
__asm
{
smull result64_lo, result64_hi, L_var2, L_var1
mov result64_hi, result64_hi, asl #5
#ifdef EXTENDED_ASM
mov result64_lo, result64_lo, lsr #27
orr result64_hi, result64_lo, result64_hi
#else
orr result64_hi, result64_hi, result64_lo, lsr #27
#endif
}
return (result64_hi);
}
__inline Int32 fxp_mul32_Q26(const Int32 L_var1, const Int32 L_var2)
{
Int32 result64_hi;
Int32 result64_lo;
__asm
{
smull result64_lo, result64_hi, L_var2, L_var1
mov result64_hi, result64_hi, asl #6
#ifdef EXTENDED_ASM
mov result64_lo, result64_lo, lsr #26
orr result64_hi, result64_lo, result64_hi
#else
orr result64_hi, result64_hi, result64_lo, lsr #26
#endif
}
return (result64_hi);
}
__inline Int32 fxp_mul32_Q20(const Int32 L_var1, const Int32 L_var2)
{
Int32 result64_hi;
Int32 result64_lo;
__asm
{
smull result64_lo, result64_hi, L_var2, L_var1
mov result64_hi, result64_hi, asl #12
#ifdef EXTENDED_ASM
mov result64_lo, result64_lo, lsr #20
orr result64_hi, result64_lo, result64_hi
#else
orr result64_hi, result64_hi, result64_lo, lsr #20
#endif
}
return (result64_hi);
}
__inline Int32 fxp_mul32_by_16(Int32 L_var1, const Int32 L_var2)
{
Int32 result64_hi;
__asm
{
smulwb result64_hi, L_var1, L_var2
}
return (result64_hi);
}
#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16(a, b)
__inline Int32 fxp_mul32_by_16t(Int32 L_var1, const Int32 L_var2)
{
Int32 result64_hi;
__asm
{
smulwt result64_hi, L_var1, L_var2
}
return (result64_hi);
}
__inline Int32 fxp_mul32_Q15(const Int32 L_var1, const Int32 L_var2)
{
Int32 result64_hi;
Int32 result64_lo;
__asm
{
smull result64_lo, result64_hi, L_var2, L_var1
mov result64_hi, result64_hi, asl #17
#ifdef EXTENDED_ASM
mov result64_lo, result64_lo, lsr #15
orr result64_hi, result64_lo, result64_hi
#else
orr result64_hi, result64_hi, result64_lo, lsr #15
#endif
}
return (result64_hi);
}
__inline Int32 cmplx_mul32_by_16(Int32 L_var1, const Int32 L_var2, const Int32 cmplx)
{
Int32 result64_hi;
__asm
{
smulwt result64_hi, L_var1, cmplx
smlawb result64_hi, L_var2, cmplx, result64_hi
}
return (result64_hi);
}
__inline Int32 fxp_mul32_Q14(const Int32 L_var1, const Int32 L_var2)
{
Int32 result64_hi;
Int32 result64_lo;
__asm
{
smull result64_lo, result64_hi, L_var2, L_var1
mov result64_hi, result64_hi, asl #18
#ifdef EXTENDED_ASM
mov result64_lo, result64_lo, lsr #14
orr result64_hi, result64_lo, result64_hi
#else
orr result64_hi, result64_hi, result64_lo, lsr #14
#endif
}
return (result64_hi);
}
#define preload_cache( a)
#endif
#ifdef __cplusplus
}
#endif
#endif /* FXP_MUL32 */

View File

@@ -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.
* -------------------------------------------------------------------
*/
/*
Pathname: ./c/include/fxp_mul32_c_equivalent.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
------------------------------------------------------------------------------
*/
#ifndef FXP_MUL32_C_EQUIVALENT
#define FXP_MUL32_C_EQUIVALENT
#ifdef __cplusplus
extern "C"
{
#endif
#include "pv_audio_type_defs.h"
#if defined(C_EQUIVALENT)
#define preload_cache( a)
__inline Int32 shft_lft_1(Int32 L_var1)
{
if (((L_var1 << 1) >> 1) == L_var1)
L_var1 <<= 1;
else
L_var1 = ((L_var1 >> 31) ^ INT32_MAX);
return (L_var1);
}
__inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, Int32 L_var2)
{
L_var2 = (L_var2 << 16) >> 16;
L_var1 = (L_var1 << 16) >> 16;
L_var1 *= L_var2;
return L_var1;
}
#define fxp_mul_16_by_16(a, b) fxp_mul_16_by_16bb( a, b)
__inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, Int32 L_var2)
{
L_var2 = (L_var2 << 16) >> 16;
L_var1 = L_var1 >> 16;
L_var1 *= L_var2;
return L_var1;
}
__inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, Int32 L_var2)
{
L_var2 = L_var2 >> 16;
L_var1 = (L_var1 << 16) >> 16;
L_var1 *= L_var2;
return L_var1;
}
__inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, Int32 L_var2)
{
L_var2 = L_var2 >> 16;
L_var1 = L_var1 >> 16;
L_var1 *= L_var2;
return L_var1;
}
__inline Int32 fxp_mac_16_by_16(Int16 L_var1, Int16 L_var2, Int32 L_add)
{
L_add += L_var1 * L_var2;
return L_add;
}
__inline Int32 fxp_mac_16_by_16_bb(Int16 L_var1, Int32 L_var2, Int32 L_add)
{
L_var2 = (L_var2 << 16) >> 16;
L_add += L_var1 * L_var2;
return L_add;
}
__inline Int32 fxp_mac_16_by_16_bt(Int16 L_var1, Int32 L_var2, Int32 L_add)
{
L_var2 = L_var2 >> 16;
L_add += L_var1 * L_var2;
return L_add;
}
__inline Int32 cmplx_mul32_by_16(Int32 x, const Int32 y, Int32 exp_jw)
{
Int32 rTmp0 = (Int16)(exp_jw >> 16);
Int32 iTmp0 = exp_jw;
Int32 z;
z = (Int32)(((int64_t)x * (rTmp0 << 16)) >> 32);
z += (Int32)(((int64_t)y * (iTmp0 << 16)) >> 32);
return (z);
}
__inline Int32 fxp_mul32_by_16(Int32 L_var1, const Int32 L_var2)
{
Int32 z;
z = (Int32)(((int64_t) L_var1 * (L_var2 << 16)) >> 32);
return(z);
}
#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16( a, b)
__inline Int32 fxp_mul32_by_16t(Int32 L_var1, const Int32 L_var2)
{
Int32 rTmp0 = (Int16)(L_var2 >> 16);
Int32 z;
z = (Int32)(((int64_t) L_var1 * (rTmp0 << 16)) >> 32);
return(z);
}
__inline Int32 fxp_mac32_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
{
Int32 rTmp0 = L_var2 << 16;
L_add += (Int32)(((int64_t) L_var1 * rTmp0) >> 32);
return(L_add);
}
__inline int64_t fxp_mac64_Q31(int64_t sum, const Int32 L_var1, const Int32 L_var2)
{
sum += (int64_t)L_var1 * L_var2;
return (sum);
}
__inline Int32 fxp_mul32_Q31(const Int32 a, const Int32 b)
{
return (Int32)(((int64_t)(a) * b) >> 32);
}
__inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b)
{
return (L_add + (Int32)(((int64_t)(a) * b) >> 32));
}
__inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b)
{
return (L_sub - (Int32)(((int64_t)(a) * b) >> 32));
}
__inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b)
{
return (Int32)(((int64_t)(a) * b) >> 30);
}
__inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add)
{
return (L_add + (Int32)(((int64_t)(a) * b) >> 30));
}
__inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b)
{
return (Int32)(((int64_t)(a) * b) >> 29);
}
__inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add)
{
return (L_add + (Int32)(((int64_t)(a) * b) >> 29));
}
__inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub)
{
return (L_sub - (Int32)(((int64_t)(a) * b) >> 29));
}
__inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b)
{
return (Int32)(((int64_t)(a) * b) >> 28);
}
__inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b)
{
return (Int32)(((int64_t)(a) * b) >> 27);
}
__inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b)
{
return (Int32)(((int64_t)(a) * b) >> 26);
}
__inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b)
{
return (Int32)(((int64_t)(a) * b) >> 20);
}
__inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b)
{
return (Int32)(((int64_t)(a) * b) >> 15);
}
__inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b)
{
return (Int32)(((int64_t)(a) * b) >> 14);
}
#endif
#ifdef __cplusplus
}
#endif
#endif /* FXP_MUL32 */

View File

@@ -0,0 +1,254 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: fxp_mul32_msc_evc.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
------------------------------------------------------------------------------
*/
#ifndef FXP_MUL32_MSC_EVC
#define FXP_MUL32_MSC_EVC
#ifdef __cplusplus
extern "C"
{
#endif
#include "pv_audio_type_defs.h"
#if defined(PV_ARM_MSC_EVC_V4)
#include "cmnintrin.h"
#define preload_cache( a)
__inline Int32 shft_lft_1(Int32 L_var1)
{
if (((L_var1 << 1) >> 1) == L_var1)
L_var1 <<= 1;
else
L_var1 = ((L_var1 >> 31) ^ INT32_MAX);
return L_var1;
}
__inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, Int32 L_var2)
{
L_var2 = (L_var2 << 16) >> 16;
L_var1 = (L_var1 << 16) >> 16;
return (L_var1*L_var2);
}
#define fxp_mul_16_by_16(a, b) fxp_mul_16_by_16bb( a, b)
__inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, Int32 L_var2)
{
L_var2 = (L_var2 << 16) >> 16;
L_var1 = L_var1 >> 16;
return (L_var1*L_var2);
}
__inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, Int32 L_var2)
{
L_var2 = L_var2 >> 16;
L_var1 = (L_var1 << 16) >> 16;
return (L_var1*L_var2);
}
__inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, Int32 L_var2)
{
L_var2 = L_var2 >> 16;
L_var1 = L_var1 >> 16;
return (L_var1*L_var2);
}
__inline Int32 fxp_mac_16_by_16(Int16 L_var1, Int16 L_var2, Int32 L_add)
{
return (L_add + (L_var1*L_var2));
}
__inline Int32 fxp_mac_16_by_16_bb(Int16 L_var1, Int32 L_var2, Int32 L_add)
{
L_var2 = (L_var2 << 16) >> 16;
return (L_add + (L_var1*L_var2));
}
__inline Int32 fxp_mac_16_by_16_bt(Int16 L_var1, Int32 L_var2, Int32 L_add)
{
L_var2 = L_var2 >> 16;
return (L_add + (L_var1*L_var2));
}
__inline Int32 cmplx_mul32_by_16(Int32 x, const Int32 y, Int32 exp_jw)
{
Int32 rTmp0 = (exp_jw >> 16) << 16;
Int32 iTmp0 = exp_jw << 16;
Int32 z;
z = _MulHigh(rTmp0, x);
z += _MulHigh(iTmp0, y);
return (z);
}
__inline Int32 fxp_mul32_by_16(Int32 L_var1, const Int32 L_var2)
{
Int32 rTmp0 = L_var2 << 16;
return(_MulHigh(rTmp0, L_var1));
}
#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16( a, b)
__inline Int32 fxp_mul32_by_16t(Int32 L_var1, const Int32 L_var2)
{
Int32 rTmp0 = (Int16)(L_var2 >> 16);
return(_MulHigh((rTmp0 << 16), L_var1));
}
__inline Int32 fxp_mac32_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
{
Int32 rTmp0 = (L_var2 << 16);
return(L_add + _MulHigh(rTmp0, L_var1));
}
__inline int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2)
{
sum += (int64)L_var1 * L_var2;
return (sum);
}
#define fxp_mul32_Q31( a, b) _MulHigh( b, a)
__inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b)
{
return (L_add + _MulHigh(b, a));
}
__inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b)
{
return (L_sub - _MulHigh(b, a));
}
__inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b)
{
return (Int32)(((int64)(a) * b) >> 30);
}
__inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add)
{
return (L_add + (Int32)(((int64)(a) * b) >> 30));
}
__inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b)
{
return (Int32)(((int64)(a) * b) >> 29);
}
__inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add)
{
return (L_add + (Int32)(((int64)(a) * b) >> 29));
}
__inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub)
{
return (L_sub - (Int32)(((int64)(a) * b) >> 29));
}
__inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b)
{
return (Int32)(((int64)(a) * b) >> 28);
}
__inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b)
{
return (Int32)(((int64)(a) * b) >> 27);
}
__inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b)
{
return (Int32)(((int64)(a) * b) >> 26);
}
__inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b)
{
return (Int32)(((int64)(a) * b) >> 20);
}
__inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b)
{
return (Int32)(((int64)(a) * b) >> 15);
}
__inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b)
{
return (Int32)(((int64)(a) * b) >> 14);
}
#endif
#ifdef __cplusplus
}
#endif
#endif /* FXP_MUL32 */

View File

@@ -0,0 +1,178 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: .fxp_mul32_msc_evc_armv5.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
------------------------------------------------------------------------------
*/
#ifndef FXP_MUL32_MSC_EVC_ARMV5
#define FXP_MUL32_MSC_EVC_ARMV5
#ifdef __cplusplus
extern "C"
{
#endif
#include "pv_audio_type_defs.h"
#if defined(PV_ARM_MSC_EVC_V5)
#include "armintr.h"
#include "cmnintrin.h"
#define preload_cache( a)
#define shft_lft_1( L_var1) _AddSatInt( L_var1, L_var1)
#define fxp_mul_16_by_16bb( L_var1, L_var2) _SmulLo_SW_SL( L_var1, L_var2)
#define fxp_mul_16_by_16(a, b) fxp_mul_16_by_16bb( a, b)
#define fxp_mul_16_by_16tb( L_var1, L_var2) _SmulHiLo_SW_SL( L_var1, L_var2)
#define fxp_mul_16_by_16bt( L_var1, L_var2) _SmulLoHi_SW_SL( L_var1, L_var2)
#define fxp_mul_16_by_16tt( L_var1, L_var2) _SmulHi_SW_SL( L_var1, L_var2)
#define fxp_mac_16_by_16( L_var1, L_var2, L_add) _SmulAddLo_SW_SL( L_add, L_var1, L_var2)
#define fxp_mac_16_by_16_bb(a, b, c) fxp_mac_16_by_16( a, b, c)
#define fxp_mac_16_by_16_bt( L_var1, L_var2, L_add) _SmulAddLoHi_SW_SL( L_add, L_var1, L_var2)
__inline Int32 cmplx_mul32_by_16(Int32 L_var1, const Int32 L_var2, const Int32 cmplx)
{
Int32 result64_hi;
result64_hi = _SmulWHi_SW_SL(L_var1, cmplx);
result64_hi = _SmulAddWLo_SW_SL(result64_hi, L_var2, cmplx);
return (result64_hi);
}
#define fxp_mul32_by_16( L_var1, L_var2) _SmulWLo_SW_SL( L_var1, L_var2)
#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16( a, b)
#define fxp_mul32_by_16t( L_var1, L_var2) _SmulWHi_SW_SL( L_var1, L_var2)
#define fxp_mac32_by_16( L_var1, L_var2, L_add) _SmulAddWLo_SW_SL( L_add, L_var1, L_var2)
__inline int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2)
{
sum += (int64)L_var1 * L_var2;
return (sum);
}
#define fxp_mul32_Q31( a, b) _MulHigh( b, a)
__inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b)
{
return (L_add + _MulHigh(b, a));
}
__inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b)
{
return (L_sub - _MulHigh(b, a));
}
__inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b)
{
return (Int32)(((int64)(a) * b) >> 30);
}
__inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add)
{
return (L_add + (Int32)(((int64)(a) * b) >> 30));
}
__inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b)
{
return (Int32)(((int64)(a) * b) >> 29);
}
__inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add)
{
return (L_add + (Int32)(((int64)(a) * b) >> 29));
}
__inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub)
{
return (L_sub - (Int32)(((int64)(a) * b) >> 29));
}
__inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b)
{
return (Int32)(((int64)(a) * b) >> 28);
}
__inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b)
{
return (Int32)(((int64)(a) * b) >> 27);
}
__inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b)
{
return (Int32)(((int64)(a) * b) >> 26);
}
__inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b)
{
return (Int32)(((int64)(a) * b) >> 20);
}
__inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b)
{
return (Int32)(((int64)(a) * b) >> 15);
}
__inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b)
{
return (Int32)(((int64)(a) * b) >> 14);
}
#endif
#ifdef __cplusplus
}
#endif
#endif /* FXP_MUL32 */

View File

@@ -0,0 +1,55 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: .fxp_mul32_pentium.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
------------------------------------------------------------------------------
*/
#ifndef FXP_MUL32_PENTIUM
#define FXP_MUL32_PENTIUM
#ifdef __cplusplus
extern "C"
{
#endif
#include "pv_audio_type_defs.h"
#ifdef __cplusplus
}
#endif
#endif /* FXP_MUL32 */

View File

@@ -0,0 +1,512 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
------------------------------------------------------------------------------
REVISION HISTORY
Description: Modified from original shareware code
Description: Modified to remove instances of pow() and sqrt(), and
optimized for inclusion in fixed-point version of decoder.
Description: Modified to include comments/optimizations from code review.
Also, declared appropriate variables as type "const"
Description: Adopted strategy of "one q-format per sfb" strategy, which
eliminated the array q-format from this function. The q-format the
random vector is stored in is now returned from the function.
Description: Completely redesigned the routine to allow a simplified
calculation of the adjusted noise, by eliminating the dependency
on the band_length. Added polynomial approximation for the
function 1/sqrt(power). Updated comments and pseudo-code
Description: Modified function description, pseudocode, etc.
Description:
Modified casting to ensure proper operations for different platforms
Description:
Eliminiated access to memory for noise seed. Now a local variable is
used. Also unrolled loops to speed up code.
Description:
Modified pointer decrement to a pointer increment, to ensure proper
compiler behavior
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Inputs: random_array[] = Array for storage of the power-scaled
random values of length "band_length"
Int32
band_length = Length of random_array[]
const Int
pSeed = seed for random number generator
Int32*
power_scale = scale factor for this particular band
const Int
Local Stores/Buffers/Pointers Needed:
None
Global Stores/Buffers/Pointers Needed:
None
Outputs: Function returns the q-format the random vector is stored in.
Pointers and Buffers Modified:
random_array[] = filled with random numbers scaled
to the correct power as defined by the input value power_scale.
Local Stores Modified:
None
Global Stores Modified:
None
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
This function generates a vector of uniformly distributed random numbers for
the PNS block. The random numbers are each scaled by a scale_factor,
defined in Ref(2) as
2^(scale_factor/4)
------------------
sqrt(N*MEAN_NRG)
where N == band_length, and MEAN_NRG is defined as...
N-1
___
1 \
--- > x(i)^2
N /__
i=0
And x is the unscaled vector from the random number generator.
This function takes advantage of the fact that the portion of the
scale_factor that is divisible by 4 can be simply accounted for by varying
the q-format.
The scaling of the random numbers is thus broken into the
equivalent equation below.
2^(scale_factor%4) 2^(floor(scale_factor/4))
------------------ *
sqrt(N*MEAN_NRG)
2^(scale_factor%4) is stored in a simple 4-element table.
2^(floor(scale_factor/4) is accounted for by adjusting the q-format.
sqrt(N*MEAN_NRG) is calculated and implemented via a polynomial approximation.
------------------------------------------------------------------------------
REQUIREMENTS
This function shall produce uniformly distributed random 32-bit integers,
with signed random values of average energy equal to the results of the ISO
code's multiplying factor discussed in the FUNCTION DESCRIPTION section.
Please see Ref (2) for a detailed description of the requirements.
------------------------------------------------------------------------------
REFERENCES
(1) Numerical Recipes in C Second Edition
William H. Press Saul A. Teukolsky
William T. Vetterling Brian P. Flannery
Page 284
(2) ISO/IEC 14496-3:1999(E)
Part 3
Subpart 4.6.12 (Perceptual Noise Substitution)
(3) MPEG-2 NBC Audio Decoder
"This software module was originally developed by AT&T, Dolby
Laboratories, Fraunhofer Gesellschaft IIS in the course of development
of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
3. This software module is an implementation of a part of one or more
MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
standards free license to this software module or modifications thereof
for use in hardware or software products claiming conformance to the
MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
module in hardware or software products are advised that this use may
infringe existing patents. The original developer of this software
module and his/her company, the subsequent editors and their companies,
and ISO/IEC have no liability for use of this software module or
modifications thereof in an implementation. Copyright is not released
for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
developer retains full right to use the code for his/her own purpose,
assign or donate the code to a third party and to inhibit third party
from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
This copyright notice must be included in all copies or derivative
works."
Copyright(c)1996.
------------------------------------------------------------------------------
PSEUDO-CODE
power_adj = scale_mod_4[power_scale & 3];
power = 0;
FOR (k=band_length; k > 0; k--)
*(pSeed) = *(pSeed) * 1664525L;
*(pSeed) = *(pSeed) + 1013904223L;
temp = (Int)(*(pSeed) >> 16);
power = power + ((temp*temp) >> 6);
*(pArray) = (Int32)temp;
pArray = pArray + 1;
ENDFOR
k = 0;
q_adjust = 30;
IF (power)
THEN
WHILE ( power > 32767)
power = power >> 1;
k = k + 1;
ENDWHILE
k = k - 13;
IF (k < 0)
THEN
k = -k;
IF ( k & 1 )
THEN
power_adj = (power_adj*SQRT_OF_2)>>14;
ENDIF
q_adjust = q_adjust - ( k >> 1);
ELSE IF (k > 0)
THEN
IF ( k & 1 )
THEN
power_adj = (power_adj*INV_SQRT_OF_2)>>14;
ENDIF
q_adjust = q_adjust + ( k >> 1);
ENDIF
pInvSqrtCoeff = inv_sqrt_coeff;
inv_sqrt_power = (*(pInvSqrtCoeff)* power) >>15;
pInvSqrtCoeff = pInvSqrtCoeff + 1;
inv_sqrt_power = inv_sqrt_power + *(pInvSqrtCoeff);
pInvSqrtCoeff = pInvSqrtCoeff + 1;
FOR ( k=INV_SQRT_POLY_ORDER - 1; k>0; k--)
inv_sqrt_power = ( inv_sqrt_power * power)>>15;
inv_sqrt_power = inv_sqrt_power + *(pInvSqrtCoeff);
pInvSqrtCoeff = pInvSqrtCoeff + 1;
ENDFOR
inv_sqrt_power = (inv_sqrt_power*power_adj)>>13;
FOR (k=band_length; k > 0; k--)
pArray = pArray - 1;
*(pArray) = *(pArray)*inv_sqrt_power;
ENDFOR
ENDIF
q_adjust = q_adjust - (power_scale >> 2);
return q_adjust;
------------------------------------------------------------------------------
RESOURCES USED
When the code is written for a specific target processor
the resources used should be documented below.
STACK USAGE: [stack count for this module] + [variable to represent
stack usage for each subroutine called]
where: [stack usage variable] = stack usage for [subroutine
name] (see [filename].ext)
DATA MEMORY USED: x words
PROGRAM MEMORY USED: x words
CLOCK CYCLES: [cycle count equation for this module] + [variable
used to represent cycle count for each subroutine
called]
where: [cycle count variable] = cycle count for [subroutine
name] (see [filename].ext)
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "gen_rand_vector.h"
#include "window_block_fxp.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
#define SQRT_OF_2 23170 /* sqrt(2) in Q14 */
#define INV_SQRT_OF_2 11585 /* 1/sqrt(2) in Q14 */
#define INV_SQRT_POLY_ORDER 4
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*
* 2^([0:3]/4) = 1.0000 1.1892 1.4142 1.6818
*/
const UInt scale_mod_4[4] = { 16384, 19484, 23170, 27554};
/*
* polynomial approx. in Q12 (type Int)
*/
const Int inv_sqrt_coeff[INV_SQRT_POLY_ORDER+1] =
{ 4680, -17935, 27697, -22326, 11980};
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
Int gen_rand_vector(
Int32 random_array[],
const Int band_length,
Int32* pSeed,
const Int power_scale)
{
Int k;
UInt power_adj;
Int q_adjust = 30;
Int32 temp;
Int32 seed;
Int32 power;
Int32* pArray = &random_array[0];
Int32 inv_sqrt_power;
const Int *pInvSqrtCoeff;
/*
* The out of the random number generator is scaled is such a way
* that is independent of the band length.
* The output is computed as:
*
* x(i)
* output = ------------------ * 2^(power_scale%4) 2^(floor(power_scale/4))
* bl
* sqrt( SUM x(i)^2 )
* 0
*
* bl == band length
*/
/*
* get 2^(power_scale%4)
*/
power = 0;
seed = *pSeed;
/*
* band_length is always an even number (check tables in pg.66 IS0 14496-3)
*/
if (band_length < 0 || band_length > LONG_WINDOW)
{
return q_adjust; /* avoid any processing on error condition */
}
for (k = (band_length >> 1); k != 0; k--)
{
/*------------------------------------------------
Numerical Recipes in C
Page 284
------------------------------------------------*/
seed *= 1664525L;
seed += 1013904223L;
temp = seed >> 16;
seed *= 1664525L;
seed += 1013904223L;
/* shift by 6 make room for band length accumulation */
power += ((temp * temp) >> 6);
*pArray++ = temp;
temp = seed >> 16;
power += ((temp * temp) >> 6);
*pArray++ = temp;
} /* END for (k=half_band_length; k > 0; k--) */
*pSeed = seed;
/*
* If the distribution is uniform, the power is expected to use between
* 28 and 27 bits, by shifting down by 13 bits the power will be a
* Q15 number.
* For different band lengths, the power uses between 20 and 29 bits
*/
k = 0;
if (power)
{
/*
* approximation requires power between 0.5 < power < 1 in Q15.
*/
while (power > 32767)
{
power >>= 1;
k++;
}
/*
* expected power bit usage == 27 bits
*/
k -= 13;
power_adj = scale_mod_4[power_scale & 3];
if (k < 0)
{
k = -k;
if (k & 1)
{ /* multiply by sqrt(2) */
power_adj = (UInt)(((UInt32) power_adj * SQRT_OF_2) >> 14);
}
q_adjust -= (k >> 1); /* adjust Q instead of shifting up */
}
else if (k > 0)
{
if (k & 1)
{ /* multiply by 1/sqrt(2) */
power_adj = (UInt)(((UInt32) power_adj * INV_SQRT_OF_2) >> 14);
}
q_adjust += (k >> 1); /* adjust Q instead of shifting down */
}
/*
* Compute 1/sqrt(power), where 0.5 < power < 1.0 is approximated
* using a polynomial order INV_SQRT_POLY_ORDER
*/
pInvSqrtCoeff = inv_sqrt_coeff;
inv_sqrt_power = (*(pInvSqrtCoeff++) * power) >> 15;
inv_sqrt_power += *(pInvSqrtCoeff++);
inv_sqrt_power = (inv_sqrt_power * power) >> 15;
inv_sqrt_power += *(pInvSqrtCoeff++);
inv_sqrt_power = (inv_sqrt_power * power) >> 15;
inv_sqrt_power += *(pInvSqrtCoeff++);
inv_sqrt_power = (inv_sqrt_power * power) >> 15;
inv_sqrt_power += *(pInvSqrtCoeff);
inv_sqrt_power = (inv_sqrt_power * power_adj) >> 13;
pArray = &random_array[0];
for (k = (band_length >> 1); k != 0; k--)
{
temp = *(pArray) * inv_sqrt_power;
*(pArray++) = temp;
temp = *(pArray) * inv_sqrt_power;
*(pArray++) = temp;
} /* END for (k=half_band_length; k > 0; k--) */
} /* if(power) */
/*
* Adjust Q with the value corresponding to 2^(floor(power_scale/4))
*/
q_adjust -= (power_scale >> 2);
return (q_adjust);
} /* gen_rand_vector */

View File

@@ -0,0 +1,87 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: gen_rand_vector.h
------------------------------------------------------------------------------
REVISION HISTORY
Description: Added include of pv_audio_type_defs.h
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
This include file contains the function declaration for gen_rand_vector.
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef gen_rand_vector_H
#define gen_rand_vector_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
Int gen_rand_vector(
Int32 random_array[],
const Int band_length,
Int32 *pSeed,
const Int power_scale);
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,443 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: get_adif_header.c
------------------------------------------------------------------------------
REVISION HISTORY
Description: Modified from original shareware code
Description: Modified to pass variables by reference to eliminate use
of global variables.
Description: Change to PV template, remove default config parameter,
move some functionality into get_prog_config().
Description: Update per code review
1) Add parameter pScratchPCE
2) Change way ADIF_ID is read in.
3) Fix comments
4) ADD a test for status != SUCCESS in loop.
Description: The ADIF_Header has now been delegated to the "scratch memory"
union. This change inside s_tDec_Int_File.h had to be reflected here also.
Description: Updated the SW template to include the full pathname to the
source file and a slightly modified copyright header.
Who: Date:
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Inputs:
pVars = pointer to the structure that contains the current state
of this instance of the library, of data type pointer to
tDec_Int_File
pScratchPCE = pointer to a ProgConfig structure used as scratch in the
the function get_prog_config. of data type pointer to
ProgConfig
Local Stores/Buffers/Pointers Needed: None
Global Stores/Buffers/Pointers Needed: None
Outputs:
The function returns 0 if no error occurred, non-zero otherwise.
Pointers and Buffers Modified:
pVars->adif_header contents are updated with the some of the ADIF header
contents
pVars->tempProgConfig contents are overwritten with last PCE found,
which is most likely the first one found.
pVars->prog_config contents are updated with the first PCE found.
pVars->inputStream contents are modify in such a way that the
stream is moved further along in the buffer.
pVars->SFBWidth128 contents may be updated.
pVars->winSeqInfo contents may be updated.
pScratchPCE contents may be updated.
Local Stores Modified: None
Global Stores Modified: None
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
This function reads in the ADIF Header found at the front of ADIF streams.
If the header is not found an error is returned. An ADIF header can contain
from zero to sixteen program configuration elements (PCE). This function, and
the rest of the library, saves and uses the first PCE found.
------------------------------------------------------------------------------
REQUIREMENTS
Function shall not use static or global variables.
------------------------------------------------------------------------------
REFERENCES
(1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding
of moving pictures and associated audio information - Part 7: Advanced
Audio Coding (AAC)", Table 6.21 - Syntax of program_config_element(),
page 16, and section 8.5 "Program Config Element (PCE)", page 30.
(2) MPEG-2 NBC Audio Decoder
"This software module was originally developed by AT&T, Dolby
Laboratories, Fraunhofer Gesellschaft IIS in the course of development
of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
3. This software module is an implementation of a part of one or more
MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
standards free license to this software module or modifications thereof
for use in hardware or software products claiming conformance to the
MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
module in hardware or software products are advised that this use may
infringe existing patents. The original developer of this software
module and his/her company, the subsequent editors and their companies,
and ISO/IEC have no liability for use of this software module or
modifications thereof in an implementation. Copyright is not released
for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
developer retains full right to use the code for his/her own purpose,
assign or donate the code to a third party and to inhibit third party
from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
This copyright notice must be included in all copies or derivative
works."
Copyright(c)1996.
------------------------------------------------------------------------------
PSEUDO-CODE
CALL getbits(
neededBits = 2 * LEN_BYTE,
pInputStream = pInputStream)
MODIFYING( pInputStream )
RETURNING( theIDFromFile )
CALL getbits(
neededBits = 2 * LEN_BYTE,
pInputStream = pInputStream)
MODIFYING( pInputStream )
RETURNING( temp )
theIDFromFile = (theIDFromFile << (2*LEN_BYTE)) | temp;
IF (theIDFromFile != ADIF_ID)
THEN
pInputStream->usedBits -= (4 * LEN_BYTE);
status = -1;
ELSE
CALL getbits(
neededBits = LEN_COPYRT_PRES,
pInputStream = pInputStream)
MODIFYING( pInputStream )
RETURNING( temp )
IF (temp != FALSE) THEN
FOR (i = LEN_COPYRT_ID; i > 0; i--)
CALL getbits(
neededBits = LEN_BYTE,
pInputStream = pInputStream)
MODIFYING( pInputStream )
END FOR
END IF
CALL getbits(
neededBits = LEN_ORIG + LEN_HOME,
pInputStream = pInputStream)
MODIFYING( pInputStream )
CALL getbits(
neededBits = LEN_BS_TYPE,
pInputStream = pInputStream)
MODIFYING( pInputStream )
RETURNING( bitStreamType )
CALL getbits(
neededBits = LEN_BIT_RATE,
pInputStream = pInputStream)
MODIFYING( pInputStream )
RETURNING( pHeader->bitrate )
CALL getbits(
neededBits = LEN_NUM_PCE,
pInputStream = pInputStream)
MODIFYING( pInputStream )
RETURNING( numConfigElementsMinus1 )
FOR ( i = numConfigElementsMinus1;
(i >= 0) && (status == SUCCESS);
i--)
IF (bitStreamType == CONSTANT_RATE_BITSTREAM) THEN
CALL getbits(
neededBits = LEN_ADIF_BF,
pInputStream = pInputStream)
MODIFYING( pInputStream )
END IF
CALL get_prog_config(
pVars = pVars)
MODIFYING( pVars->prog_config )
RETURNING( status )
END FOR
END IF
RETURN (status)
------------------------------------------------------------------------------
RESOURCES USED
When the code is written for a specific target processor the
the resources used should be documented below.
STACK USAGE: [stack count for this module] + [variable to represent
stack usage for each subroutine called]
where: [stack usage variable] = stack usage for [subroutine
name] (see [filename].ext)
DATA MEMORY USED: x words
PROGRAM MEMORY USED: x words
CLOCK CYCLES: [cycle count equation for this module] + [variable
used to represent cycle count for each subroutine
called]
where: [cycle count variable] = cycle count for [subroutine
name] (see [filename].ext)
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "e_adif_const.h"
#include "s_progconfig.h"
#include "s_adif_header.h"
#include "s_bits.h"
#include "s_mc_info.h"
#include "s_frameinfo.h"
#include "s_tdec_int_file.h"
#include "get_prog_config.h"
#include "ibstream.h"
#include "get_adif_header.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*
* This constant is simply the characters 'A' 'D' 'I' 'F' compressed into
* a UInt32. Any possible endian problems that exist must be solved by
* the function that fills the buffer and getbits(), or this constant and
* the rest of the bit stream will not work.
*/
#define ADIF_ID (0x41444946)
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL VARIABLE DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
Int get_adif_header(
tDec_Int_File *pVars,
ProgConfig *pScratchPCE)
{
Int i;
UInt32 temp;
Int numConfigElementsMinus1;
Int bitStreamType;
UInt32 theIDFromFile;
BITS *pInputStream = &pVars->inputStream;
ADIF_Header *pHeader = &pVars->scratch.adif_header;
Int status = SUCCESS;
/*
* The ADIF_ID field is 32 bits long, one more than what getbits() can
* do, so read the field in two parts. There is no point in saving the
* string - it either matches or it does not. If it matches, it must
* have been 'ADIF'
*/
theIDFromFile = get17_n_lessbits((2 * LEN_BYTE), pInputStream);
temp = get17_n_lessbits((2 * LEN_BYTE), pInputStream);
theIDFromFile = (theIDFromFile << (2 * LEN_BYTE)) | temp;
if (theIDFromFile != ADIF_ID)
{
/*
* Rewind the bit stream pointer so a search for ADTS header
* can start at the beginning.
*/
pInputStream->usedBits -= (4 * LEN_BYTE);
/*
* The constant in the next line needs to be updated when
* error handling method is determined.
*/
status = -1;
}
else
{
/*
* To save space, the unused fields are read in, but not saved.
*/
/* copyright string */
temp =
get1bits(/* LEN_COPYRT_PRES,*/
pInputStream);
if (temp != FALSE)
{
/*
* Read in and ignore the copyright string. If restoring
* watch out for count down loop.
*/
for (i = LEN_COPYRT_ID; i > 0; i--)
{
get9_n_lessbits(LEN_BYTE,
pInputStream);
} /* end for */
/*
* Make sure to terminate the string with '\0' if restoring
* the the copyright string.
*/
} /* end if */
/* Combine the original/copy and fields into one call */
get9_n_lessbits(
LEN_ORIG + LEN_HOME,
pInputStream);
bitStreamType =
get1bits(/* LEN_BS_TYPE,*/
pInputStream);
pHeader->bitrate =
getbits(
LEN_BIT_RATE,
pInputStream);
/*
* Read in all the Program Configuration Elements.
* For this library, only one of the up to 16 possible PCE's will be
* saved. Since each PCE must be read, a temporary PCE structure is
* used, and if that PCE is the one to use, it is copied into the
* single PCE. This is done inside of get_prog_config()
*/
numConfigElementsMinus1 = get9_n_lessbits(LEN_NUM_PCE,
pInputStream);
for (i = numConfigElementsMinus1;
(i >= 0) && (status == SUCCESS);
i--)
{
/*
* For ADIF contant bit rate streams, the _encoder_ buffer
* fullness is transmitted. This version of an AAC decoder has
* no use for this variable; yet it must be read in to move
* the bitstream pointers.
*/
if (bitStreamType == CONSTANT_RATE_BITSTREAM)
{
getbits(
LEN_ADIF_BF,
pInputStream);
} /* end if */
pVars->adif_test = 1;
/* Get one program configuration element */
status =
get_prog_config(
pVars,
pScratchPCE);
#ifdef AAC_PLUS
/*
* For implicit signalling, no hint that sbr or ps is used, so we need to
* check the sampling frequency of the aac content, if lesser or equal to
* 24 KHz, by defualt upsample, otherwise, do nothing
*/
if ((pVars->prog_config.sampling_rate_idx >= 6) && (pVars->aacPlusEnabled == true) &&
pVars->mc_info.audioObjectType == MP4AUDIO_AAC_LC)
{
pVars->mc_info.upsamplingFactor = 2;
pVars->prog_config.sampling_rate_idx -= 3;
pVars->mc_info.sbrPresentFlag = 1;
pVars->sbrDecoderData.SbrChannel[0].syncState = UPSAMPLING;
pVars->sbrDecoderData.SbrChannel[1].syncState = UPSAMPLING;
}
#endif
} /* end for */
} /* end 'else' of --> if (theIDFromFile != ADIF_ID) */
return status;
} /* end get_adif_header */

View File

@@ -0,0 +1,95 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: get_adif_header.h
------------------------------------------------------------------------------
REVISION HISTORY
Description: Add parameter to get_adif_header() function.
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
Header file for get_adif_header.c
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef GET_ADIF_HEADER_H
#define GET_ADIF_HEADER_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "s_tdec_int_file.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
#define CONSTANT_RATE_BITSTREAM (0)
#define VARIABLE_RATE_BITSTREAM (1)
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
Int get_adif_header(
tDec_Int_File *pVars,
ProgConfig *pScratchPCE);
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,672 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: get_adts_header.c
------------------------------------------------------------------------------
REVISION HISTORY
Description: Remove default_config variable
Description: change enter_mc_info to set_mc_info
Description: (1) add error checking for channel_config > 2
(2) eliminated call to check_mc_info
(3) use (profile + 1) when calling set_mc_info
(4) use winmap when calling set_mc_info
Who: Date:
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Inputs:
pVars = Pointer to structure that holds file-scope variables.
[ tDec_Int_File * ]
pSyncword = Pointer to variable that holds the 28-bit fixed
header upon the exit of this function. [ UInt32 * ]
pInvoke = Pointer to variable that keeps track of how many
"short" (14 bit) headers have been successfully
parsed from the bitstream. [ Int * ]
Local Stores/Buffers/Pointers Needed:
None
Global Stores/Buffers/Pointers Needed:
None
Outputs:
Status = SUCCESS or ERROR CODE
Pointers and Buffers Modified:
pVars->prog_config Updated with program information data as read from
the ADTS header.
pSyncword Value pointed to is updated with the contents of
the 28-bit fixed header.
pInvoke Value pointed to is updated to reflect the number
of successful "short" (14 bit) headers that have
been successfully parsed from the bitstream.
Local Stores Modified:
None
Global Stores Modified:
None
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
Acronym Definitions
ADTS Audio Data Transport Stream
CRC Cyclic Redundancy Code
This function calls find_adts_syncword to find the next ADTS header. Until
three consistent headers have been read, the syncword used for detection
consists of the 12-bit syncword and the 2-bit Layer. After three consistent
headers are read, the entire fixed header is used for a robust 28-bit
syncword.
Configuration information is then extracted from the bitstream.
The bitstream information is packed as follows.
Comments about the correct interpretation of these bits are contained within
the code.
CRC_absent sampling_rate_idx
\ / \
\ / \
\ Profile / \ UNUSED
\ / \ / \ /
|00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|
\ _______________ / | \ / \ /
\-------|0xFFF syncword |-------/ | Layer == '00' for AAC \ /
\-------------/ | \ /
| \/
ID == '1' for MPEG-2 AAC channel_config
copyright_id_bit == '0' for MPEG-4 AAC
/
home /
/ /
|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|
| \ \ _____________ /
| \ \--------|frame length |---------/
orig_copy \ \-----------/
\ ______________________________
copyright_id_start | TOTAL HEADER LENGTH: 56 bits|
|-----------------------------|
|43|44|45|46|47|48|49|50|51|52|53|54|55| | FIXED HEADER BITS 00-27 |
\ _______________ / | | | VARIABLE HEADER BITS 28-55 |
\-----|buffer_fullness|----/ \ / |_____________________________|
\-------------/ |
headerless_frames
In addition to the bits displayed above, if the value CRC_absent is '0' an
additional 16 bits corresponding to a CRC word are read from the bitstream,
following the header.
------------------------------------------------------------------------------
REQUIREMENTS
After the ADTS syncword is detected, this function shall parse the
information residing behind the syncword in the bitstream.
------------------------------------------------------------------------------
REFERENCES
(1) ISO/IEC 13818-7:1997(E)
Part 7
Subpart 6.2 (Audio_Data_Transport_Stream frame, ADTS)
(2) ISO/IEC 11172-3:1993(E)
Part 3
Subpart 2.4.3 The audio decoding process
(3) MPEG-2 NBC Audio Decoder
"This software module was originally developed by AT&T, Dolby
Laboratories, Fraunhofer Gesellschaft IIS in the course of development
of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
3. This software module is an implementation of a part of one or more
MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
standards free license to this software module or modifications thereof
for use in hardware or software products claiming conformance to the
MPEG-2 NBC/MPEG-4 Audio standards. Those UIntending to use this software
module in hardware or software products are advised that this use may
infringe existing patents. The original developer of this software
module and his/her company, the subsequent editors and their companies,
and ISO/IEC have no liability for use of this software module or
modifications thereof in an implementation. Copyright is not released
for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
developer retains full right to use the code for his/her own purpose,
assign or donate the code to a third party and to inhibit third party
from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
This copyright notice must be included in all copies or derivative
works."
Copyright(c)1996.
------------------------------------------------------------------------------
PSEUDO-CODE
IF (*(pInvoke) > 3)
CALL find_adts_syncword(
pSyncword,
&(pVars->inputStream),
LENGTH_FIXED_HEADER,
MASK_28BITS);
RETURNING status
ELSE
*(pSyncword) = SYNCWORD_15BITS;
CALL find_adts_syncword(
pSyncword,
&(pVars->inputStream),
LENGTH_SYNCWORD,
ID_BIT_FILTER);
MODIFYING *(pSyncword) = 28-bit fixed header (long syncword)
RETURNING status
CALL getbits(
(LENGTH_FIXED_HEADER - LENGTH_SYNCWORD),
&(pVars->inputStream));
MODIFYING pVars->inputStream
RETURNING adts_header = remaining bits in the fixed header
*(pSyncword) <<= 13;
*(pSyncword) = *(pSyncword) OR adts_header;
pVars->prog_config.CRC_absent = ((UInt)(adts_header >> 12)) AND 0x0001;
lower_16 = (UInt)adts_header;
pVars->prog_config.profile = (lower_16 >> 10) AND 0x3;
pVars->prog_config.sampling_rate_idx = (lower_16 >> 6) AND 0xF;
channel_configuration = (lower_16 >> 2) AND 0x7;
channel_configuration = channel_configuration - 1;
pVars->prog_config.front.ele_is_cpe[0] = channel_configuration;
pVars->prog_config.front.num_ele = 1;
pVars->prog_config.front.ele_tag[0] = 0;
pVars->prog_config.mono_mix.present = 0;
pVars->prog_config.stereo_mix.present = 0;
pVars->prog_config.matrix_mix.present = 0;
CALL set_mc_info(
&(pVars->mc_info),
&(pVars->savedMCInfo),
&(pVars->prog_config),
pVars->pWinSeqInfo,
pVars->SFBWidth128);
MODIFYING pVars->mc_info = multi-channel configuration information
RETURNING status = SUCCESS/FAILURE
IF ( (*pInvoke) != 0)
CALL check_mc_info(
&(pVars->mc_info),
&(pVars->savedMCInfo),
FALSE);
RETURNING status = SUCCESS/FAILURE
ELSE
CALL check_mc_info(
&(pVars->mc_info),
&(pVars->savedMCInfo),
TRUE);
MODIFYING pVars->savedMCInfo = pVars->mc_info
RETURNING status = SUCCESS/FAILURE
ENDIF
IF (status == SUCCESS)
(*pInvoke) = (*pInvoke) + 1;
ELSE
(*pInvoke) = 0;
ENDIF
ENDIF
CALL getbits(
LENGTH_VARIABLE_HEADER,
&(pVars->inputStream));
RETURNING adts_header = 28-bits (the contents of the variable header.)
pVars->prog_config.frame_length = ((UInt)(adts_header >> 13)) AND 0x1FFF;
lower_16 = (UInt)adts_header;
pVars->prog_config.buffer_fullness = (lower_16 >> 2) AND 0x7FF;
pVars->prog_config.headerless_frames = (lower_16 AND 0x0003);
IF (pVars->prog_config.CRC_absent == 0)
CALL getbits(
LENGTH_CRC,
&(pVars->inputStream) );
RETURNING pVars->prog_config.CRC_check = 16-bit CRC
ENDIF
pVars->default_config = 0;
IF (byte_align_offset > 7)
status = 1;
ENDIF
return (status);
------------------------------------------------------------------------------
RESOURCES USED
When the code is written for a specific target processor the
the resources used should be documented below.
STACK USAGE: [stack count for this module] + [variable to represent
stack usage for each subroutine called]
where: [stack usage variable] = stack usage for [subroutine
name] (see [filename].ext)
DATA MEMORY USED: x words
PROGRAM MEMORY USED: x words
CLOCK CYCLES: [cycle count equation for this module] + [variable
used to represent cycle count for each subroutine
called]
where: [cycle count variable] = cycle count for [subroutine
name] (see [filename].ext)
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "s_bits.h"
#include "s_tdec_int_file.h"
#include "ibstream.h"
#include "set_mc_info.h"
#include "find_adts_syncword.h"
#include "get_adts_header.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
#define LENGTH_VARIABLE_HEADER 28
#define LENGTH_FIXED_HEADER 28
#define LENGTH_SYNCWORD 15
#define LENGTH_CRC 16
#define ID_BIT_FILTER 0x7FFB
#define SYNCWORD_15BITS 0x7FF8
#define MASK_28BITS 0x0FFFFFFFL
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
Int get_adts_header(
tDec_Int_File *pVars,
UInt32 *pSyncword,
Int *pInvoke,
Int CorrectlyReadFramesCount)
{
UInt32 adts_header;
UInt lower_16;
Int status = SUCCESS;
UInt channel_configuration;
/*
* Search for the LONG ADTS syncword (comprised of the entire fixed header)
* if the number of CorrectlyReadFrames is > CorrectlyReadFramesCount
*
* Otherwise, search for just the short syncword.
*/
if (*(pInvoke) > CorrectlyReadFramesCount)
{
/*
* Find the long ADTS syncword
* (comprised of the entire ADTS fixed header)
*/
status = find_adts_syncword(pSyncword,
&(pVars->inputStream),
LENGTH_FIXED_HEADER,
MASK_28BITS);
}
else
{
*(pSyncword) = SYNCWORD_15BITS;
status = find_adts_syncword(pSyncword,
&(pVars->inputStream),
LENGTH_SYNCWORD,
ID_BIT_FILTER);
/*
* Extract the data from the header following the syncword
*/
adts_header = getbits((LENGTH_FIXED_HEADER - LENGTH_SYNCWORD),
&(pVars->inputStream));
*(pSyncword) <<= (LENGTH_FIXED_HEADER - LENGTH_SYNCWORD);
*(pSyncword) |= adts_header;
/* Denotes whether a CRC check should be performed */
pVars->prog_config.CRC_absent = ((UInt)(adts_header >> 12)) & 0x0001;
/*
* All the unread bits in adts_header reside in the lower
* 16-bits at this point. Perform a typecast for faster
* execution on 16-bit processors.
*/
lower_16 = (UInt)adts_header;
/*
* Profile consists of 2 bits, which indicate
* the profile used.
*
* '00' AAC_MAIN profile
* '01' AAC_LC (Low Complexity) profile
* '10' AAC_SSR (Scaleable Sampling Rate) profile
* '11' AAC_LTP (Long Term Prediction) profile
*/
pVars->prog_config.profile = (lower_16 >> 10) & 0x3;
if (pVars->prog_config.profile == MP4AUDIO_AAC_SSR)
{
status = 1; /* Not supported */
}
/*
* Sampling_rate_idx consists of 4 bits
* see Ref #1 for their interpretation.
*/
pVars->prog_config.sampling_rate_idx = (lower_16 >> 6) & 0xF;
/*
* private_bit is a bit for private use. ISO/IEC will not make
* use of this bit in the future.
*
* We currently make no use of it, but parsing the information
* from the bitstream could be easily implemented with the
* following instruction...
*
* private_bit = (lower_16 & 0x0400) >> 10;
*/
/*
* These 3 bits indicate the channel configuration used.
*
* If '0' then the channel configuration is unspecified here,
* and must be given by a program configuration element in
* the raw data block.
*
* If '1' then the channel configuration is MONO.
* If '2' then the channel configuration is STEREO
*
* 3-7 represent channel configurations which this library
* will not support in the forseeable future.
*/
channel_configuration = (lower_16 >> 2) & 0x7;
/* do not support more than 2 channels */
if (channel_configuration > 2)
{
status = 1;
}
/*
* The following 2 bits encode copyright information.
* original_copy is '0' if there is no copyright in the bitstream.
* '1' if the bitstream is copyright protected.
*
* home is '0' for a copy, '1' for an original.
*
* PacketVideo currently does nothing with this information,
* however, parsing the data from the bitstream could be easily
* implemented with the following instructions...
*
* original_copy = (lower_16 >> 1) & 0x1;
*
* home = (lower_16 & 0x1);
*
*/
/* Set up based on information extracted from the ADTS FIXED header */
/* This equals 1 for STEREO, 0 for MONO */
if (channel_configuration)
{
channel_configuration--;
}
pVars->prog_config.front.ele_is_cpe[0] = channel_configuration;
/* This value is constant for both MONO and STEREO */
pVars->prog_config.front.num_ele = 1;
/* ADTS does not specify this tag value - do we even use it? */
pVars->prog_config.front.ele_tag[0] = 0;
/* Disable all mix related variables */
pVars->prog_config.mono_mix.present = 0;
pVars->prog_config.stereo_mix.present = 0;
pVars->prog_config.matrix_mix.present = 0;
/* enter configuration into MC_Info structure */
if (status == SUCCESS)
{
/* profile + 1 == audioObjectType */
status =
set_mc_info(
&(pVars->mc_info),
(tMP4AudioObjectType)(pVars->prog_config.profile + 1),
pVars->prog_config.sampling_rate_idx,
pVars->prog_config.front.ele_tag[0],
pVars->prog_config.front.ele_is_cpe[0],
pVars->winmap, /* changed from pVars->pWinSeqInfo, */
pVars->SFBWidth128);
} /* if (status == SUCCESS) */
#ifdef AAC_PLUS
/*
* For implicit signalling, no hint that sbr or ps is used, so we need to
* check the sampling frequency of the aac content, if lesser or equal to
* 24 KHz, by defualt upsample, otherwise, do nothing
*/
if ((pVars->prog_config.sampling_rate_idx >= 6) && (pVars->aacPlusEnabled == TRUE))
{
pVars->mc_info.upsamplingFactor = 2;
pVars->prog_config.sampling_rate_idx -= 3;
pVars->mc_info.sbrPresentFlag = 1;
pVars->sbrDecoderData.SbrChannel[0].syncState = SBR_ACTIVE;
pVars->sbrDecoderData.SbrChannel[1].syncState = SBR_ACTIVE;
}
#endif
/*
* The tag and is_cpe will be checked in huffdecode,
* remove this check routine.
*/
/*if (status == SUCCESS)
*{
* if ( (*pInvoke) != 0)
* {
* status =
* check_mc_info(
* &(pVars->mc_info),
* &(pVars->savedMCInfo),
* FALSE);
* }
* else
* {
* status =
* check_mc_info(
* &(pVars->mc_info),
* &(pVars->savedMCInfo),
* TRUE);
* }
*
*}*/ /* if (status == SUCCESS) */
/*
* This keeps track of how many headers have been read in the file.
* After the three successful headers with the same configuration
* are read in, the entire ADTS fixed header is used as the syncword
* for a more robust 28-bit long syncword
*/
if (status == SUCCESS)
{
(*pInvoke)++;
}
else
{
(*pInvoke) = 0;
}
} /* END if (*(pInvoke) > 3) */
/* Grab the bits in the ADTS variable header */
adts_header = getbits(
LENGTH_VARIABLE_HEADER,
&(pVars->inputStream));
/*
* copyright_identification bit is a single bit of the 72-bit
* copyright_id field. This consists of a 8-bit copyright identifier
* and a 64-bit copyright_number. 72 headers must be decoded
* to reconstruct the entire copyright_id field.
*
* copyright_identification_start is a single bit flagging
* the beginning bit of the copyright_id field. '1' for start of
* copyright_id, '0' otherwise.
*
*
* PacketVideo currently does nothing with this information,
* however, parsing the data from the bitstream could be easily
* implemented with the following instructions...
*
* copyright_id_bit = ((UInt)(adts_header >> 27)) & 0x1;
*
* copyright_id_start = ((UInt)(adts_header >> 26)) & 0x1;
*/
/*
* frame_length is a 13-bit field which indicates the length,
* in bytes, of the frame including error_check and headers.
* This information can theoretically be used to help verify syncwords.
*/
pVars->prog_config.frame_length = ((UInt)(adts_header >> 13)) & 0x1FFF;
/*
* All the unread bits in adts_header reside in the lower
* 16-bits at this point. Perform a typecast for faster
* execution on 16-bit processors.
*/
lower_16 = (UInt)adts_header;
/*
* Indicates the number of 32-bit words remaining in the
* encoder buffer after the encoding of the first raw
* data block. This value is 0x7ff for variable bit
* rate encoders, since buffer fullness does not apply
* to Variable Bit Rate (VBR) encoders.
*/
pVars->prog_config.buffer_fullness = (lower_16 >> 2) & 0x7FF;
/*
* headerless_frames indicates the number of
* frames with no headers to be processed before the reading
* in of the next header.
*
* In ADTS, up to 4 "no header frames" can exist between
* syncwords.
*
* EXAMPLES:
*
* Legend: (Sync words denoted by X, frames
* deonted by FRAME_#)
*
* Example(1): The ADTS sequence below packs 5
* frames per header.
* Here, headerless_frames would always be read in as "4"
*
* |X||FRAME_0||FRAME_1||FRAME_2||FRAME_3||FRAME_4||X||FRAME_0|
*
* Example(2): The ADTS sequence below packs 1 frame per header.
* Here, headerless_frames would always be read in as "0"
*
* |X||FRAME_0||X||FRAME_1||X||FRAME_2|
*
*/
pVars->prog_config.headerless_frames = (lower_16 & 0x0003);
if (pVars->prog_config.CRC_absent == 0)
{
pVars->prog_config.CRC_check = (UInt)getbits(
LENGTH_CRC,
&(pVars->inputStream));
}
/* pVars->current_program = 0; */ /* shall be set after PCE is read */
return (status);
} /* END get_adts_header */

View File

@@ -0,0 +1,90 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./include/get_adts_header.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
This include file has the function declaration for get_adts_header().
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef GET_ADTS_HEADER_H
#define GET_ADTS_HEADER_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "s_tdec_int_file.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
Int get_adts_header(
tDec_Int_File *pVars,
UInt32 *pSyncword,
Int *pInvoke,
Int CorrectlyReadFramesCount);
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,691 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./src/get_audio_specific_config.c
------------------------------------------------------------------------------
REVISION HISTORY
Description: Modified per review comments
Description: Modified per second review comments
(1) change audioObjectType to Int
(2) do not set pVars->prog_config.profile
(3) clean up status flag, default to SUCCESS
(4) fix multiple lines comments
Description: Change getbits.h to ibstream.h
Description: Modified per review comments
(1) updated revision history
(2) declare audioObjectType as enum type
Description: Replace some instances of getbits to get9_n_lessbits
when the number of bits read is 9 or less.
Description: Added support for backward and non-backward (explicit)
mode for Parametric Stereo (PS) used in enhanced AAC+
Who: Date:
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Inputs:
pVars = pointer to the structure that holds all information for
this instance of the library. pVars->prog_config is directly
used, and pVars->mc_info, pVars->prog_config,
pVars->pWinSeqInfo, pVars->SFBWidth128 are needed indirectly
for calling set_mc_info. Data type pointer to tDec_Int_File
Local Stores/Buffers/Pointers Needed:
None
Global Stores/Buffers/Pointers Needed:
None
Outputs:
status = 0 if successfully decoded AudioSpecificConfig
1 if un-supported config is used for this release
Pointers and Buffers Modified:
pVars->prog_config contents are updated with the information read in.
pVars->mc_info contents are updated with channel information.
pVars->pWinSeqInfo contents are updated with window information.
pVars->SFBWidth128 contents are updated with scale factor band width data.
Local Stores Modified:
None
Global Stores Modified:
None
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
This function reads the bitstream for the structure "AudioSpecificConfig",
and sets the decoder configuration that is needed by the decoder to be able
to decode the media properly.
------------------------------------------------------------------------------
REQUIREMENTS
This function shall not use global variables
------------------------------------------------------------------------------
REFERENCES
(1) ISO/IEC 14496-3: 1999(E)
Part 3
Subpart 1 p18 1.6 Interface to MPEG-4 Systems
Subpart 4 p13 4.4.1 GA Specific Configuration
Amendment p10 6.2.1 AudioSpecificInfo
Amendment p78 8.2 Decoder configuration (GASpecificConfig)
(2) AAC DecoderSpecificInfo Information
PacketVideo descriptions - San Diego
------------------------------------------------------------------------------
PSEUDO-CODE
status = SUCCESS;
pInputStream = &(pVars->inputStream);
temp = CALL getbits(
neededBits = LEN_OBJ_TYPE + LEN_SAMP_RATE_IDX,
pInputStream = pInputStream)
MODIFYING (pInputStream)
RETURNING (temp)
audioObjectType = (temp & 0x1f0) >> 4;
pVars->prog_config.profile = audioObjectType;
pVars->prog_config.sampling_rate_idx = temp & 0xf;
IF (pVars->prog_config.sampling_rate_idx == 0xf)
THEN
sampling_rate = CALL getbits(
neededBits = LEN_SAMP_RATE,
pInputStream = pInputStream);
MODIFYING (pInputStream)
RETURNING (sampling_rate)
ENDIF
channel_config = CALL getbits(
neededBits = LEN_CHAN_CONFIG,
pInputStream = pInputStream);
MODIFYING (pInputStream)
RETURNING (channel_config)
IF (channel_config > 2)
THEN
status = 1;
ENDIF
IF (((audioObjectType == MP4AUDIO_AAC_MAIN) OR
(audioObjectType == MP4AUDIO_AAC_LC) OR
(audioObjectType == MP4AUDIO_AAC_SSR) OR
(audioObjectType == MP4AUDIO_LTP) OR
(audioObjectType == MP4AUDIO_AAC_SCALABLE) OR
(audioObjectType == MP4AUDIO_TWINVQ)) AND (status == -1))
THEN
status = CALL get_GA_specific_config(
pVars = pVars,
channel_config = channel_config,
audioObjectType = audioObjectType,
pInputStream = pInputStream);
MODIFYING (pVars->mc_info,channel_config,pInputStream)
RETURNING (status)
ENDIF
IF (audioObjectType == MP4AUDIO_CELP)
THEN
status = 1;
ENDIF
IF (audioObjectType == MP4AUDIO_HVXC)
THEN
status = 1;
ENDIF
IF (audioObjectType == MP4AUDIO_TTSI)
THEN
status = 1;
ENDIF
IF ((audioObjectType == 13) OR (audioObjectType == 14) OR
(audioObjectType == 15) OR (audioObjectType == 16))
THEN
status = 1;
ENDIF
IF (((audioObjectType == MP4AUDIO_ER_AAC_LC) OR
(audioObjectType == MP4AUDIO_ER_AAC_LTP) OR
(audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) OR
(audioObjectType == MP4AUDIO_ER_TWINVQ) OR
(audioObjectType == MP4AUDIO_ER_BSAC) OR
(audioObjectType == MP4AUDIO_ER_AAC_LD)) AND (status == -1))
THEN
status = 1;
ENDIF
IF (audioObjectType == MP4AUDIO_ER_CELP)
THEN
status = 1;
ENDIF
IF (audioObjectType == MP4AUDIO_ER_HVXC)
THEN
status = 1;
ENDIF
IF ((audioObjectType == MP4AUDIO_ER_HILN) OR
(audioObjectType == MP4AUDIO_PARAMETRIC))
THEN
status = 1;
ENDIF
IF ((audioObjectType == MP4AUDIO_ER_AAC_LC) OR
(audioObjectType == MP4AUDIO_ER_AAC_LTP) OR
(audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) OR
(audioObjectType == MP4AUDIO_ER_TWINVQ) OR
(audioObjectType == MP4AUDIO_ER_BSAC) OR
(audioObjectType == MP4AUDIO_ER_AAC_LD) OR
(audioObjectType == MP4AUDIO_ER_CELP) OR
(audioObjectType == MP4AUDIO_ER_HVXC) OR
(audioObjectType == MP4AUDIO_ER_HILN) OR
(audioObjectType == MP4AUDIO_PARAMETRIC))
THEN
epConfig = CALL getbits(
neededBits = LEN_EP_CONFIG,
pInputStream = pInputStream);
MODIFYING (pInputStream)
RETURNING (epConfig)
IF (epConfig == 2)
THEN
status = 1;
ENDIF
ENDIF
RETURN status;
------------------------------------------------------------------------------
RESOURCES USED
When the code is written for a specific target processor the
the resources used should be documented below.
STACK USAGE: [stack count for this module] + [variable to represent
stack usage for each subroutine called]
where: [stack usage variable] = stack usage for [subroutine
name] (see [filename].ext)
DATA MEMORY USED: x words
PROGRAM MEMORY USED: x words
CLOCK CYCLES: [cycle count equation for this module] + [variable
used to represent cycle count for each subroutine
called]
where: [cycle count variable] = cycle count for [subroutine
name] (see [filename].ext)
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "e_mp4ff_const.h"
#include "e_tmp4audioobjecttype.h"
#include "get_audio_specific_config.h"
#include "get_ga_specific_config.h"
#include "ibstream.h"
#include "sfb.h" /* Where samp_rate_info[] is declared */
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
Int get_audio_specific_config(tDec_Int_File * const pVars)
{
UInt temp;
tMP4AudioObjectType audioObjectType;
//UInt32 sampling_rate;
UInt channel_config;
UInt syncExtensionType;
UInt extensionAudioObjectType = 0;
UInt extensionSamplingFrequencyIndex = 0;
BITS *pInputStream;
Int status;
status = SUCCESS;
pInputStream = &(pVars->inputStream);
pVars->mc_info.upsamplingFactor = 1; /* default to regular AAC */
temp = get9_n_lessbits(LEN_OBJ_TYPE + LEN_SAMP_RATE_IDX,
pInputStream);
/*
* The following code can directly set the values of elements in
* MC_Info, rather than first setting the values in pVars->prog_config
* and then copy these values to MC_Info by calling set_mc_info.
* In order to keep consistent with get_prog_config (ADIF) and
* get_adts_header (ADTS), the code here is still copying
* the info, and set the pVars->current_program = 0
*/
/* AudioObjectType */
audioObjectType = (tMP4AudioObjectType)((temp & 0x1f0) >> 4);
pVars->mc_info.ExtendedAudioObjectType = audioObjectType; /* default */
/* saving an audioObjectType into a profile field */
/* pVars->prog_config.profile = audioObjectType; */
/* sampling rate index */
pVars->prog_config.sampling_rate_idx = temp & 0xf;
if (pVars->prog_config.sampling_rate_idx > 0xb)
{
/*
* Only support 12 sampling frequencies from array samp_rate_info ( see sfb.cpp)
* 7350 Hz (index 0xc) is not supported, the other indexes are reserved or escape
*/
if (pVars->prog_config.sampling_rate_idx == 0xf) /* escape sequence */
{
/*
* sampling rate not listed in Table 1.6.2,
* this release does not support this
*/
/*sampling_rate = getbits( LEN_SAMP_RATE,
pInputStream);*/
getbits(LEN_SAMP_RATE, pInputStream); /* future use */
}
status = 1;
}
channel_config = get9_n_lessbits(LEN_CHAN_CONFIG,
pInputStream);
if ((channel_config > 2) && (!pVars->aacConfigUtilityEnabled))
{
/*
* AAC lib does not support more than two channels
* signal error when in decoder mode
* do not test when in utility mode
*/
status = 1;
}
if (audioObjectType == MP4AUDIO_SBR || audioObjectType == MP4AUDIO_PS)
{
/* to disable explicit backward compatiblity check */
pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR;
pVars->mc_info.sbrPresentFlag = 1;
if (audioObjectType == MP4AUDIO_PS)
{
pVars->mc_info.psPresentFlag = 1;
pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_PS;
}
extensionSamplingFrequencyIndex = /* extensionSamplingFrequencyIndex */
get9_n_lessbits(LEN_SAMP_RATE_IDX,
pInputStream);
if (extensionSamplingFrequencyIndex == 0x0f)
{
/*
* sampling rate not listed in Table 1.6.2,
* this release does not support this
*/
/*sampling_rate = getbits( LEN_SAMP_RATE,
pInputStream);*/
getbits(LEN_SAMP_RATE, pInputStream);
}
audioObjectType = (tMP4AudioObjectType) get9_n_lessbits(LEN_OBJ_TYPE ,
pInputStream);
}
if ((/*(audioObjectType == MP4AUDIO_AAC_MAIN) ||*/
(audioObjectType == MP4AUDIO_AAC_LC) ||
/*(audioObjectType == MP4AUDIO_AAC_SSR) ||*/
(audioObjectType == MP4AUDIO_LTP) /*||*/
/*(audioObjectType == MP4AUDIO_AAC_SCALABLE) ||*/
/*(audioObjectType == MP4AUDIO_TWINVQ)*/) && (status == SUCCESS))
{
status = get_GA_specific_config(pVars,
pInputStream,
channel_config,
audioObjectType);
/*
* verify that Program config returned a supported audio object type
*/
if ((pVars->mc_info.audioObjectType != MP4AUDIO_AAC_LC) &&
(pVars->mc_info.audioObjectType != MP4AUDIO_LTP))
{
return 1; /* status != SUCCESS invalid aot */
}
}
else
{
return 1; /* status != SUCCESS invalid aot or invalid parameter */
}
/*
* SBR tool explicit signaling ( backward compatible )
*/
if (extensionAudioObjectType != MP4AUDIO_SBR)
{
syncExtensionType = (UInt)get17_n_lessbits(LEN_SYNC_EXTENSION_TYPE,
pInputStream);
if (syncExtensionType == 0x2b7)
{
extensionAudioObjectType = get9_n_lessbits( /* extensionAudioObjectType */
LEN_OBJ_TYPE,
pInputStream);
if (extensionAudioObjectType == MP4AUDIO_SBR)
{
pVars->mc_info.sbrPresentFlag = get1bits(pInputStream); /* sbrPresentFlag */
if (pVars->mc_info.sbrPresentFlag == 1)
{
extensionSamplingFrequencyIndex =
get9_n_lessbits( /* extensionSamplingFrequencyIndex */
LEN_SAMP_RATE_IDX,
pInputStream);
if (pVars->aacPlusEnabled == true)
{
#ifdef AAC_PLUS
pVars->mc_info.upsamplingFactor = (samp_rate_info[extensionSamplingFrequencyIndex].samp_rate >> 1) ==
samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate ? 2 : 1;
if ((Int)extensionSamplingFrequencyIndex == pVars->prog_config.sampling_rate_idx)
{
/*
* Disable SBR decoding for any sbr-downsampled file whose SF is >= 24 KHz
*/
if (pVars->prog_config.sampling_rate_idx < 6)
{
pVars->aacPlusEnabled = false;
}
pVars->mc_info.bDownSampledSbr = true;
}
pVars->prog_config.sampling_rate_idx = extensionSamplingFrequencyIndex;
#endif
}
if (extensionSamplingFrequencyIndex == 0x0f)
{
/*
* sampling rate not listed in Table 1.6.2,
* this release does not support this
*/
/*sampling_rate = getbits( LEN_SAMP_RATE,
pInputStream);*/
getbits(LEN_SAMP_RATE, pInputStream);
}
/* syncExtensionType */
syncExtensionType = (UInt)get17_n_lessbits(LEN_SYNC_EXTENSION_TYPE,
pInputStream);
if (syncExtensionType == 0x548)
{
pVars->mc_info.psPresentFlag = get1bits(pInputStream); /* psPresentFlag */
if (pVars->mc_info.psPresentFlag)
{
extensionAudioObjectType = MP4AUDIO_PS;
}
}
else
{
/*
* Rewind bitstream pointer so that the syncExtensionType reading has no
* effect when decoding raw bitstream
*/
pVars->inputStream.usedBits -= LEN_SYNC_EXTENSION_TYPE;
}
pVars->mc_info.ExtendedAudioObjectType = (eMP4AudioObjectType)extensionAudioObjectType;
}
}
}
else if (!status)
{
/*
* Rewind bitstream pointer so that the syncExtensionType reading has no
* effect when decoding raw bitstream
*/
pVars->inputStream.usedBits -= LEN_SYNC_EXTENSION_TYPE;
#ifdef AAC_PLUS
/*
* For implicit signalling, no hint that sbr or ps is used, so we need to
* check the sampling frequency of the aac content, if lesser or equal to
* 24 KHz, by defualt upsample, otherwise, do nothing
*/
if ((pVars->prog_config.sampling_rate_idx >= 6) && (pVars->aacPlusEnabled == true) &&
audioObjectType == MP4AUDIO_AAC_LC)
{
pVars->mc_info.upsamplingFactor = 2;
pVars->prog_config.sampling_rate_idx -= 3;
pVars->mc_info.sbrPresentFlag = 1;
pVars->sbrDecoderData.SbrChannel[0].syncState = SBR_NOT_INITIALIZED;
pVars->sbrDecoderData.SbrChannel[1].syncState = SBR_NOT_INITIALIZED;
}
#endif
}
}
else /* MP4AUDIO_SBR was detected */
{
/*
* Set the real output frequency use by the SBR tool, define tentative upsample ratio
*/
if (pVars->aacPlusEnabled == true)
{
#ifdef AAC_PLUS
pVars->mc_info.upsamplingFactor = (samp_rate_info[extensionSamplingFrequencyIndex].samp_rate >> 1) ==
samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate ? 2 : 1;
if ((Int)extensionSamplingFrequencyIndex == pVars->prog_config.sampling_rate_idx)
{
/*
* Disable SBR decoding for any sbr-downsampled file whose SF is >= 24 KHz
*/
if (pVars->prog_config.sampling_rate_idx < 6)
{
pVars->aacPlusEnabled = false;
}
pVars->mc_info.bDownSampledSbr = true;
}
pVars->prog_config.sampling_rate_idx = extensionSamplingFrequencyIndex;
#endif
}
} /* if ( extensionAudioObjectType != MP4AUDIO_SBR ) */
/*
* The following object types are not supported in this release,
* however, keep these interfaces for future implementation
*/
/*
*if (audioObjectType == MP4AUDIO_CELP)
*{
* status = 1;
*}
*/
/*
*if (audioObjectType == MP4AUDIO_HVXC)
*{
* status = 1;
*}
*/
/*
*if (audioObjectType == MP4AUDIO_TTSI)
*{
* status = 1;
*}
*/
/*
*if ((audioObjectType == 13) || (audioObjectType == 14) ||
* (audioObjectType == 15) || (audioObjectType == 16))
*{
* status = 1;
*}
*/
/* The following objects are Amendment 1 objects */
/*
*if (((audioObjectType == MP4AUDIO_ER_AAC_LC) ||
* (audioObjectType == MP4AUDIO_ER_AAC_LTP) ||
* (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) ||
* (audioObjectType == MP4AUDIO_ER_TWINVQ) ||
* (audioObjectType == MP4AUDIO_ER_BSAC) ||
* (audioObjectType == MP4AUDIO_ER_AAC_LD)) && (status == -1))
*{
*/
/*
* should call get_GA_specific_config
* for this release, do not support Error Resilience
* temporary solution is set status flag and exit decoding
*/
/* status = 1;
*}
*/
/*
*if (audioObjectType == MP4AUDIO_ER_CELP)
* {
* status = 1;
*}
*/
/*
*if (audioObjectType == MP4AUDIO_ER_HVXC)
*{
* status = 1;
*}
*/
/*
*if ((audioObjectType == MP4AUDIO_ER_HILN) ||
* (audioObjectType == MP4AUDIO_PARAMETRIC))
*{
* status = 1;
*}
*/
/*
*if ((audioObjectType == MP4AUDIO_ER_AAC_LC) ||
* (audioObjectType == MP4AUDIO_ER_AAC_LTP) ||
* (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) ||
* (audioObjectType == MP4AUDIO_ER_TWINVQ) ||
* (audioObjectType == MP4AUDIO_ER_BSAC) ||
* (audioObjectType == MP4AUDIO_ER_AAC_LD) ||
* (audioObjectType == MP4AUDIO_ER_CELP) ||
* (audioObjectType == MP4AUDIO_ER_HVXC) ||
* (audioObjectType == MP4AUDIO_ER_HILN) ||
* (audioObjectType == MP4AUDIO_PARAMETRIC))
*{
*/
/* error protection config */
/*
* epConfig =
* getbits(
* LEN_EP_CONFIG,
* pInputStream);
*
* if (epConfig == 2)
* {
*/
/* should call ErrorProtectionSpecificConfig() */
/*
* status = 1;
* }
*
*}
*/
return status;
}

View File

@@ -0,0 +1,86 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: ./include/get_audio_specific_config.h
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date:
Description:
------------------------------------------------------------------------------
INCLUDE DESCRIPTION
This file includes function declaration for get_audio_specific_config
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef GET_AUDIO_SPECIFIC_CONFIG_H
#define GET_AUDIO_SPECIFIC_CONFIG_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "s_tdec_int_file.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
Int get_audio_specific_config(
tDec_Int_File * const pVars
);
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,215 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Inputs:
pInputStream = pointer to a BITS structure that holds information
regarding the input stream.
Local Stores/Buffers/Pointers Needed:
None
Global Stores/Buffers/Pointers Needed:
None
Outputs:
None
Pointers and Buffers Modified:
pInputStream->usedBits is rounded up to a number that represents the next
byte boundary.
Local Stores Modified:
None
Global Stores Modified:
None
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
Adquire Data Stream element (DSE) from raw bitstream
At this time this function just drops the information.
------------------------------------------------------------------------------
REQUIREMENTS
This function shall not use global or static variables.
------------------------------------------------------------------------------
REFERENCES
(1) MPEG-2 NBC Audio Decoder
"This software module was originally developed by AT&T, Dolby
Laboratories, Fraunhofer Gesellschaft IIS in the course of development
of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
3. This software module is an implementation of a part of one or more
MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
standards free license to this software module or modifications thereof
for use in hardware or software products claiming conformance to the
MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
module in hardware or software products are advised that this use may
infringe existing patents. The original developer of this software
module and his/her company, the subsequent editors and their companies,
and ISO/IEC have no liability for use of this software module or
modifications thereof in an implementation. Copyright is not released
for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
developer retains full right to use the code for his/her own purpose,
assign or donate the code to a third party and to inhibit third party
from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
This copyright notice must be included in all copies or derivative
works."
Copyright(c)1996.
------------------------------------------------------------------------------
PSEUDO-CODE
void byte_align(
BITS *pInputStream)
MODIFYING(pInputStream->usedBits = pInputStream->usedBits +
(pInputStream->usedBits + 7) % 8)
RETURN(nothing)
------------------------------------------------------------------------------
RESOURCES USED
STACK USAGE:
where:
DATA MEMORY USED: x words
PROGRAM MEMORY USED: x words
CLOCK CYCLES:
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "get_dse.h"
#include "ibstream.h"
#include "getbits.h"
#include "s_bits.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL VARIABLE DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
void get_dse(
Char *DataStreamBytes,
BITS *pInputStream)
{
Int i;
Int data_byte_align_flag;
UInt count;
Int esc_count;
Char *pDataStreamBytes;
pDataStreamBytes = DataStreamBytes;
/*
* Get element instance tag ( 4 bits)
* ( max of 16 per raw data block)
*/
get9_n_lessbits(LEN_TAG, pInputStream);
/*
* get data_byte_align_flag ( 1 bit0 to see if byte alignment is
* performed within the DSE
*/
data_byte_align_flag = get1bits(pInputStream);
/*
* get count ( 8 bits)
*/
count = get9_n_lessbits(LEN_D_CNT, pInputStream);
/*
* if count == 255, its value it is incremented by a
* second 8 bit value, esc_count. This final value represents
* the number of bytes in the DSE
*/
if (count == (1 << LEN_D_CNT) - 1)
{
esc_count = (Int)get9_n_lessbits(LEN_D_ESC, pInputStream); /* 8 bits */
count += esc_count;
}
/*
* Align if flag is set
*/
if (data_byte_align_flag)
{
byte_align(pInputStream);
}
for (i = count; i != 0; i--)
{
*(pDataStreamBytes++) = (Char) get9_n_lessbits(
LEN_BYTE,
pInputStream);
}
return;
} /* end get_dse */

View File

@@ -0,0 +1,87 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: get_dse.h
Funtions:
get_dse
------------------------------------------------------------------------------
REVISION HISTORY
Who: Date: MM/DD/YYYY
Description:
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef GET_DSE_H
#define GET_DSE_H
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "s_elelist.h"
#include "s_bits.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL VARIABLES REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; SIMPLE TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; ENUMERATED TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; STRUCTURES TYPEDEF'S
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; GLOBAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
void get_dse(
Char *DataStreamBytes,
BITS *pInputStream);
/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/
#endif

View File

@@ -0,0 +1,243 @@
/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/*
Pathname: get_ele_list.c
------------------------------------------------------------------------------
REVISION HISTORY
Description: Modified from original shareware code
Description: Modified to pass variables by reference to eliminate use
of global variables.
Description: Change to PacketVideo standard, rename variables.
Description: Add own header file, make pInputStream second param for speed.
Description: Changes per code review:
1) Include header file
2) Convert to count down
3) Add return (not in review)
Description:
(1) Updated copyright header
(2) Replaced include of "interface.h" with "e_ProgConfig.h"
Description: Replace some instances of getbits to get9_n_lessbits
when the number of bits read is 9 or less and get1bits
when only 1 bit is read.
Who: Date:
Description:
------------------------------------------------------------------------------
INPUT AND OUTPUT DEFINITIONS
Inputs:
pElementList = pointer to an EleList structure - only the field num_ele
needs to be set. Data type pointer to EleList.
pInputStream = pointer to a BITS structure, used by the function getbits
to provide data. Data type pointer to BITS
enableCPE = boolean value indicating the area to be read contains
a channel pair element field. Data type Bool
Local Stores/Buffers/Pointers Needed: None
Global Stores/Buffers/Pointers Needed: None
Outputs: None
Pointers and Buffers Modified:
pElementList contents are updated with information pertaining to channel
configuration.
pInputBuffer contents are updated to the next location to be read from
the input stream.
Local Stores Modified: None
Global Stores Modified: None
------------------------------------------------------------------------------
FUNCTION DESCRIPTION
This function is called several times by get_prog_config() to read in part of
the program configuration data related to channel setup.
------------------------------------------------------------------------------
REQUIREMENTS
This function shall not have static or global variables.
------------------------------------------------------------------------------
REFERENCES
(1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding
of moving pictures and associated audio information - Part 7: Advanced
Audio Coding (AAC)", Table 6.21 - Syntax of program_config_element(),
page 16, and section 8.5 "Program Config Element (PCE)", page 30.
(2) MPEG-2 NBC Audio Decoder
"This software module was originally developed by AT&T, Dolby
Laboratories, Fraunhofer Gesellschaft IIS in the course of development
of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
3. This software module is an implementation of a part of one or more
MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
standards free license to this software module or modifications thereof
for use in hardware or software products claiming conformance to the
MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
module in hardware or software products are advised that this use may
infringe existing patents. The original developer of this software
module and his/her company, the subsequent editors and their companies,
and ISO/IEC have no liability for use of this software module or
modifications thereof in an implementation. Copyright is not released
for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
developer retains full right to use the code for his/her own purpose,
assign or donate the code to a third party and to inhibit third party
from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
This copyright notice must be included in all copies or derivative
works."
Copyright(c)1996.
------------------------------------------------------------------------------
PSEUDO-CODE
elementCount = pElementList->num_ele;
FOR (index = 0; index < elementCount; index++)
IF (enableCPE != FALSE) THEN
pElementList->ele_is_cpe[index] =
getbits(LEN_ELE_IS_CPE, pInputStream);
ELSE
pElementList->ele_is_cpe[index] = 0;
END IF
pElementList->ele_tag[index] = getbits(LEN_TAG, pInputStream);
END FOR
RETURNS nothing
------------------------------------------------------------------------------
RESOURCES USED
When the code is written for a specific target processor the
the resources used should be documented below.
STACK USAGE: [stack count for this module] + [variable to represent
stack usage for each subroutine called]
where: [stack usage variable] = stack usage for [subroutine
name] (see [filename].ext)
DATA MEMORY USED: x words
PROGRAM MEMORY USED: x words
CLOCK CYCLES: [cycle count equation for this module] + [variable
used to represent cycle count for each subroutine
called]
where: [cycle count variable] = cycle count for [subroutine
name] (see [filename].ext)
------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/
#include "pv_audio_type_defs.h"
#include "s_elelist.h"
#include "s_bits.h"
#include "e_progconfigconst.h"
#include "ibstream.h"
#include "get_ele_list.h"
/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; DEFINES
; Include all pre-processor statements here. Include conditional
; compile variables also.
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL FUNCTION DEFINITIONS
; Function Prototype declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; LOCAL STORE/BUFFER/POINTER DEFINITIONS
; Variable declaration - defined here and used outside this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL FUNCTION REFERENCES
; Declare functions defined elsewhere and referenced in this module
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
; Declare variables used in this module but defined elsewhere
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
void get_ele_list(
EleList *pElementList,
BITS *pInputStream,
const Bool enableCPE)
{
Int index;
Int *pEleIsCPE;
Int *pEleTag;
pEleIsCPE = &pElementList->ele_is_cpe[0];
pEleTag = &pElementList->ele_tag[0];
for (index = pElementList->num_ele; index > 0; index--)
{
if (enableCPE != FALSE)
{
*pEleIsCPE++ = get1bits(/*LEN_ELE_IS_CPE, */pInputStream);
}
else
{
*pEleIsCPE++ = FALSE;
}
*pEleTag++ = get9_n_lessbits(LEN_TAG, pInputStream);
} /* end for (index) */
return;
} /* end get_ele_list */

Some files were not shown because too many files have changed in this diff Show More