/****************************************************************************** * * Copyright (C) 2014 The Android Open Source Project * Copyright 2003 - 2004 Open Interface North America, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT 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: #1 $ ***********************************************************************************/ /** @file @ingroup codec_internal */ /**@addgroup codec_internal*/ /**@{*/ /* * Performs an 8-point Type-II scaled DCT using the Arai-Agui-Nakajima * factorization. The scaling factors are folded into the windowing * constants. 29 adds and 5 16x32 multiplies per 8 samples. */ #include "common/bt_target.h" #include "oi_codec_sbc_private.h" #if (defined(SBC_DEC_INCLUDED) && SBC_DEC_INCLUDED == TRUE) #define AAN_C4_FIX (759250125)/* S1.30 759250125 0.707107*/ #define AAN_C6_FIX (410903207)/* S1.30 410903207 0.382683*/ #define AAN_Q0_FIX (581104888)/* S1.30 581104888 0.541196*/ #define AAN_Q1_FIX (1402911301)/* S1.30 1402911301 1.306563*/ /** Scales x by y bits to the right, adding a rounding factor. */ #ifndef SCALE #define SCALE(x, y) (((x) + (1 <<((y)-1))) >> (y)) #endif /** * Default C language implementation of a 32x32->32 multiply. This function may * be replaced by a platform-specific version for speed. * * @param u A signed 32-bit multiplicand * @param v A signed 32-bit multiplier * @return A signed 32-bit value corresponding to the 32 most significant bits * of the 64-bit product of u and v. */ INLINE OI_INT32 default_mul_32s_32s_hi(OI_INT32 u, OI_INT32 v) { OI_UINT32 u0, v0; OI_INT32 u1, v1, w1, w2, t; u0 = u & 0xFFFF; u1 = u >> 16; v0 = v & 0xFFFF; v1 = v >> 16; t = u0 * v0; t = u1 * v0 + ((OI_UINT32)t >> 16); w1 = t & 0xFFFF; w2 = t >> 16; w1 = u0 * v1 + w1; return u1 * v1 + w2 + (w1 >> 16); } #define MUL_32S_32S_HI(_x, _y) default_mul_32s_32s_hi(_x, _y) #ifdef DEBUG_DCT PRIVATE void float_dct2_8(float *RESTRICT out, OI_INT32 const *RESTRICT in) { #define FIX(x,bits) (((int)floor(0.5f+((x)*((float)(1<