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 { MUL s32OutLow, (int32_t)s16In2, (s32In1>>15) }       \
34   }
35 #else
36 #if (SBC_DSP_OPT == TRUE)
37 #define SBC_MULT_32_16_SIMPLIFIED(s16In2, s32In1, s32OutLow) \
38   s32OutLow = SBC_Multiply_32_16_Simplified((int32_t)s16In2, s32In1);
39 #else
40 #if (SBC_IPAQ_OPT == TRUE)
41 /*
42 #define SBC_MULT_32_16_SIMPLIFIED(s16In2, s32In1 , s32OutLow)
43 s32OutLow=(int32_t)((int32_t)(s16In2)*(int32_t)(s32In1>>15));
44 */
45 #define SBC_MULT_32_16_SIMPLIFIED(s16In2, s32In1, s32OutLow) \
46   s32OutLow = (int32_t)(((int64_t)(s16In2) * (int64_t)(s32In1)) >> 15);
47 #if (SBC_IS_64_MULT_IN_IDCT == TRUE)
48 #define SBC_MULT_32_32(s32In2, s32In1, s32OutLow)          \
49   {                                                        \
50     s64Temp = ((int64_t)s32In2) * ((int64_t)s32In1) >> 31; \
51     s32OutLow = (int32_t)s64Temp;                          \
52   }
53 #endif
54 #else
55 #define SBC_MULT_32_16_SIMPLIFIED(s16In2, s32In1, s32OutLow)     \
56   {                                                              \
57     s32In1Temp = s32In1;                                         \
58     s32In2Temp = (int32_t)s16In2;                                \
59                                                                  \
60     /* Multiply one +ve and the other -ve number */              \
61     if (s32In1Temp < 0) {                                        \
62       s32In1Temp ^= 0xFFFFFFFF;                                  \
63       s32In1Temp++;                                              \
64       s32OutLow = (s32In2Temp * (s32In1Temp >> 16));             \
65       s32OutLow += ((s32In2Temp * (s32In1Temp & 0xFFFF)) >> 16); \
66       s32OutLow ^= 0xFFFFFFFF;                                   \
67       s32OutLow++;                                               \
68     } else {                                                     \
69       s32OutLow = (s32In2Temp * (s32In1Temp >> 16));             \
70       s32OutLow += ((s32In2Temp * (s32In1Temp & 0xFFFF)) >> 16); \
71     }                                                            \
72     s32OutLow <<= 1;                                             \
73   }
74 #if (SBC_IS_64_MULT_IN_IDCT == TRUE)
75 #define SBC_MULT_64(s32In1, s32In2, s32OutLow, s32OutHi)                             \
76   {                                                                                  \
77     s32OutLow = (int32_t)(((int64_t)s32In1 * (int64_t)s32In2) & 0x00000000FFFFFFFF); \
78     s32OutHi = (int32_t)(((int64_t)s32In1 * (int64_t)s32In2) >> 32);                 \
79   }
80 #define SBC_MULT_32_32(s32In2, s32In1, s32OutLow)                    \
81   {                                                                  \
82     s32HiTemp = 0;                                                   \
83     SBC_MULT_64(s32In2, s32In1, s32OutLow, s32HiTemp);               \
84     s32OutLow = (((s32OutLow >> 15) & 0x1FFFF) | (s32HiTemp << 17)); \
85   }
86 #endif
87 
88 #endif
89 #endif
90 #endif
91 
92 #endif
93