diff options
Diffstat (limited to 'apps/codecs/libcook/cook_fixpoint.h')
-rw-r--r-- | apps/codecs/libcook/cook_fixpoint.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/apps/codecs/libcook/cook_fixpoint.h b/apps/codecs/libcook/cook_fixpoint.h index 83c054c527..0f12b1340a 100644 --- a/apps/codecs/libcook/cook_fixpoint.h +++ b/apps/codecs/libcook/cook_fixpoint.h | |||
@@ -35,6 +35,24 @@ | |||
35 | * in C using two 32 bit integer multiplications. | 35 | * in C using two 32 bit integer multiplications. |
36 | */ | 36 | */ |
37 | 37 | ||
38 | /* The following table is taken from libavutil/mathematics.c */ | ||
39 | const uint8_t ff_log2_tab[256]={ | ||
40 | 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, | ||
41 | 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, | ||
42 | 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, | ||
43 | 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, | ||
44 | 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, | ||
45 | 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, | ||
46 | 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, | ||
47 | 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 | ||
48 | }; | ||
49 | |||
50 | /* cplscales was moved from cookdata_fixpoint.h since only * | ||
51 | * cook_fixpoint.h should see/use it. */ | ||
52 | static const FIXPU* cplscales[5] = { | ||
53 | cplscale2, cplscale3, cplscale4, cplscale5, cplscale6 | ||
54 | }; | ||
55 | |||
38 | /** | 56 | /** |
39 | * Initialise fixed point implementation. | 57 | * Initialise fixed point implementation. |
40 | * Nothing to do for fixed point. | 58 | * Nothing to do for fixed point. |
@@ -86,6 +104,37 @@ static inline FIXP fixp_mult_su(FIXP a, FIXPU b) | |||
86 | return hb + (lb >> 16) + ((lb & 0x8000) >> 15); | 104 | return hb + (lb >> 16) + ((lb & 0x8000) >> 15); |
87 | } | 105 | } |
88 | 106 | ||
107 | /* math functions taken from libavutil/common.h */ | ||
108 | |||
109 | static inline int av_log2(unsigned int v) | ||
110 | { | ||
111 | int n = 0; | ||
112 | if (v & 0xffff0000) { | ||
113 | v >>= 16; | ||
114 | n += 16; | ||
115 | } | ||
116 | if (v & 0xff00) { | ||
117 | v >>= 8; | ||
118 | n += 8; | ||
119 | } | ||
120 | n += ff_log2_tab[v]; | ||
121 | |||
122 | return n; | ||
123 | } | ||
124 | |||
125 | /** | ||
126 | * Clips a signed integer value into the amin-amax range. | ||
127 | * @param a value to clip | ||
128 | * @param amin minimum value of the clip range | ||
129 | * @param amax maximum value of the clip range | ||
130 | * @return clipped value | ||
131 | */ | ||
132 | static inline int av_clip(int a, int amin, int amax) | ||
133 | { | ||
134 | if (a < amin) return amin; | ||
135 | else if (a > amax) return amax; | ||
136 | else return a; | ||
137 | } | ||
89 | 138 | ||
90 | /** | 139 | /** |
91 | * The real requantization of the mltcoefs | 140 | * The real requantization of the mltcoefs |