The only remaining floats are in the user interface, they are left as they should not cause a problem in practice
Unified · Split
| @@ -149,8 +149,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 148 unmodified lines | ||
| 149 | 149 | int h = rect->height / vdiv; |
| 150 | 150 | int xcenter = rect->cx * w; |
| 151 | 151 | int ycenter = rect->cy * h; |
| 152 | − float k1 = rect->k1; | |
| 153 | − float k2 = rect->k2; | |
| 152 | + int k1 = rect->k1 * (1<<24); | |
| 153 | + int k2 = rect->k2 * (1<<24); | |
| 154 | 154 | ThreadData td = { |
| 155 | 155 | .in = in, |
| 156 | 156 | .out = out, |
| @@ -162,7 +162,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 5 unmodified lines | ||
| 162 | 162 | |
| 163 | 163 | if (!rect->correction[plane]) { |
| 164 | 164 | int i,j; |
| 165 | − const float r2inv = 4.0 / (w * w + h * h); | |
| 165 | + const int64_t r2inv = (4LL<<60) / (w * w + h * h); | |
| 166 | 166 | |
| 167 | 167 | rect->correction[plane] = av_malloc_array(w, h * sizeof(**rect->correction)); |
| 168 | 168 | if (!rect->correction[plane]) |
| @@ -172,9 +172,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 3 unmodified lines | ||
| 172 | 172 | const int off_y2 = off_y * off_y; |
| 173 | 173 | for (i = 0; i < w; i++) { |
| 174 | 174 | const int off_x = i - xcenter; |
| 175 | − const float r2 = (off_x * off_x + off_y2) * r2inv; | |
| 176 | − const float radius_mult = 1.0f + r2 * k1 + r2 * r2 * k2; | |
| 177 | − rect->correction[plane][j * w + i] = lrintf(radius_mult * (1<<24)); | |
| 175 | + const int64_t r2 = ((off_x * off_x + off_y2) * r2inv + (1LL<<31)) >> 32; | |
| 176 | + const int64_t r4 = (r2 * r2 + (1<<27)) >> 28; | |
| 177 | + const int radius_mult = (r2 * k1 + r4 * k2 + (1LL<<27) + (1LL<<52))>>28; | |
| 178 | + rect->correction[plane][j * w + i] = radius_mult; | |
| 178 | 179 | } |
| 179 | 180 | } |
| 180 | 181 | } |