Home | History | Annotate | Download | only in include
      1 /******************************************************************************
      2  *
      3  *  Copyright 1999-2012 Broadcom Corporation
      4  *
      5  *  Licensed under the Apache License, Version 2.0 (the "License");
      6  *  you may not use this file except in compliance with the License.
      7  *  You may obtain a copy of the License at:
      8  *
      9  *  http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  *  Unless required by applicable law or agreed to in writing, software
     12  *  distributed under the License is distributed on an "AS IS" BASIS,
     13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  *  See the License for the specific language governing permissions and
     15  *  limitations under the License.
     16  *
     17  ******************************************************************************/
     18 
     19 /******************************************************************************
     20  *
     21  *  Definitions for the fast DCT.
     22  *
     23  ******************************************************************************/
     24 
     25 #ifndef SBC_DCT_H
     26 #define SBC_DCT_H
     27 
     28 #include "sbc_enc_func_declare.h"
     29 
     30 #if (SBC_ARM_ASM_OPT == TRUE)
     31 #define SBC_MULT_32_16_SIMPLIFIED(s16In2, s32In1, s32OutLow) \
     32   {                                                          \
     33     __asm {																				\
     34     MUL s32OutLow,(int32_t)s16In2, (s32In1>>15) } \
     35   }
     36 #else
     37 #if (SBC_DSP_OPT == TRUE)
     38 #define SBC_MULT_32_16_SIMPLIFIED(s16In2, s32In1, s32OutLow) \
     39   s32OutLow = SBC_Multiply_32_16_Simplified((int32_t)s16In2, s32In1);
     40 #else
     41 #if (SBC_IPAQ_OPT == TRUE)
     42 /*
     43 #define SBC_MULT_32_16_SIMPLIFIED(s16In2, s32In1 , s32OutLow)
     44 s32OutLow=(int32_t)((int32_t)(s16In2)*(int32_t)(s32In1>>15));
     45 */
     46 #define SBC_MULT_32_16_SIMPLIFIED(s16In2, s32In1, s32OutLow) \
     47   s32OutLow = (int32_t)(((int64_t)(s16In2) * (int64_t)(s32In1)) >> 15);
     48 #if (SBC_IS_64_MULT_IN_IDCT == TRUE)
     49 #define SBC_MULT_32_32(s32In2, s32In1, s32OutLow)          \
     50   {                                                        \
     51     s64Temp = ((int64_t)s32In2) * ((int64_t)s32In1) >> 31; \
     52     s32OutLow = (int32_t)s64Temp;                          \
     53   }
     54 #endif
     55 #else
     56 #define SBC_MULT_32_16_SIMPLIFIED(s16In2, s32In1, s32OutLow)     \
     57   {                                                              \
     58     s32In1Temp = s32In1;                                         \
     59     s32In2Temp = (int32_t)s16In2;                                \
     60                                                                  \
     61     /* Multiply one +ve and the other -ve number */              \
     62     if (s32In1Temp < 0) {                                        \
     63       s32In1Temp ^= 0xFFFFFFFF;                                  \
     64       s32In1Temp++;                                              \
     65       s32OutLow = (s32In2Temp * (s32In1Temp >> 16));             \
     66       s32OutLow += ((s32In2Temp * (s32In1Temp & 0xFFFF)) >> 16); \
     67       s32OutLow ^= 0xFFFFFFFF;                                   \
     68       s32OutLow++;                                               \
     69     } else {                                                     \
     70       s32OutLow = (s32In2Temp * (s32In1Temp >> 16));             \
     71       s32OutLow += ((s32In2Temp * (s32In1Temp & 0xFFFF)) >> 16); \
     72     }                                                            \
     73     s32OutLow <<= 1;                                             \
     74   }
     75 #if (SBC_IS_64_MULT_IN_IDCT == TRUE)
     76 #define SBC_MULT_64(s32In1, s32In2, s32OutLow, s32OutHi)                     \
     77   {                                                                          \
     78     s32OutLow =                                                              \
     79         (int32_t)(((int64_t)s32In1 * (int64_t)s32In2) & 0x00000000FFFFFFFF); \
     80     s32OutHi = (int32_t)(((int64_t)s32In1 * (int64_t)s32In2) >> 32);         \
     81   }
     82 #define SBC_MULT_32_32(s32In2, s32In1, s32OutLow)                    \
     83   {                                                                  \
     84     s32HiTemp = 0;                                                   \
     85     SBC_MULT_64(s32In2, s32In1, s32OutLow, s32HiTemp);               \
     86     s32OutLow = (((s32OutLow >> 15) & 0x1FFFF) | (s32HiTemp << 17)); \
     87   }
     88 #endif
     89 
     90 #endif
     91 #endif
     92 #endif
     93 
     94 #endif
     95