Originally committed as revision 22345 to svn://svn.ffmpeg.org/ffmpeg/trunk
| ... | ... |
@@ -128,28 +128,6 @@ |
| 128 | 128 |
|
| 129 | 129 |
/* math */ |
| 130 | 130 |
|
| 131 |
-extern const uint8_t ff_sqrt_tab[256]; |
|
| 132 |
- |
|
| 133 |
-static inline av_const unsigned int ff_sqrt(unsigned int a) |
|
| 134 |
-{
|
|
| 135 |
- unsigned int b; |
|
| 136 |
- |
|
| 137 |
- if (a < 255) return (ff_sqrt_tab[a + 1] - 1) >> 4; |
|
| 138 |
- else if (a < (1 << 12)) b = ff_sqrt_tab[a >> 4] >> 2; |
|
| 139 |
-#if !CONFIG_SMALL |
|
| 140 |
- else if (a < (1 << 14)) b = ff_sqrt_tab[a >> 6] >> 1; |
|
| 141 |
- else if (a < (1 << 16)) b = ff_sqrt_tab[a >> 8] ; |
|
| 142 |
-#endif |
|
| 143 |
- else {
|
|
| 144 |
- int s = av_log2_16bit(a >> 16) >> 1; |
|
| 145 |
- unsigned int c = a >> (s + 2); |
|
| 146 |
- b = ff_sqrt_tab[c >> (s + 8)]; |
|
| 147 |
- b = FASTDIV(c,b) + (b << s); |
|
| 148 |
- } |
|
| 149 |
- |
|
| 150 |
- return b - (a < b * b); |
|
| 151 |
-} |
|
| 152 |
- |
|
| 153 | 131 |
#if ARCH_X86 |
| 154 | 132 |
#define MASK_ABS(mask, level)\ |
| 155 | 133 |
__asm__ volatile(\ |
| ... | ... |
@@ -56,4 +56,26 @@ extern const uint32_t ff_inverse[257]; |
| 56 | 56 |
|
| 57 | 57 |
#endif /* FASTDIV */ |
| 58 | 58 |
|
| 59 |
+extern const uint8_t ff_sqrt_tab[256]; |
|
| 60 |
+ |
|
| 61 |
+static inline av_const unsigned int ff_sqrt(unsigned int a) |
|
| 62 |
+{
|
|
| 63 |
+ unsigned int b; |
|
| 64 |
+ |
|
| 65 |
+ if (a < 255) return (ff_sqrt_tab[a + 1] - 1) >> 4; |
|
| 66 |
+ else if (a < (1 << 12)) b = ff_sqrt_tab[a >> 4] >> 2; |
|
| 67 |
+#if !CONFIG_SMALL |
|
| 68 |
+ else if (a < (1 << 14)) b = ff_sqrt_tab[a >> 6] >> 1; |
|
| 69 |
+ else if (a < (1 << 16)) b = ff_sqrt_tab[a >> 8] ; |
|
| 70 |
+#endif |
|
| 71 |
+ else {
|
|
| 72 |
+ int s = av_log2_16bit(a >> 16) >> 1; |
|
| 73 |
+ unsigned int c = a >> (s + 2); |
|
| 74 |
+ b = ff_sqrt_tab[c >> (s + 8)]; |
|
| 75 |
+ b = FASTDIV(c,b) + (b << s); |
|
| 76 |
+ } |
|
| 77 |
+ |
|
| 78 |
+ return b - (a < b * b); |
|
| 79 |
+} |
|
| 80 |
+ |
|
| 59 | 81 |
#endif /* AVUTIL_INTMATH_H */ |