History

avfilter/vf_lenscorrection: get rid of floats in init code

The only remaining floats are in the user interface, they are left as they should not cause a problem in practice

Michael Niedermayer committed 12 years ago

Commit 32cb6c11 parent 2450ca01 file · +7 −6Browse files

Unified · Split

libavfilter/vf_lenscorrection.c+7−6
@@ -149,8 +149,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 148 unmodified lines
149 int h = rect->height / vdiv;149 int h = rect->height / vdiv;
150 int xcenter = rect->cx * w;150 int xcenter = rect->cx * w;
151 int ycenter = rect->cy * h;151 int ycenter = rect->cy * h;
152 float k1 = rect->k1;152 int k1 = rect->k1 * (1<<24);
153 float k2 = rect->k2;153 int k2 = rect->k2 * (1<<24);
154 ThreadData td = {154 ThreadData td = {
155 .in = in,155 .in = in,
156 .out = out,156 .out = out,
@@ -162,7 +162,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 5 unmodified lines
162 162
163 if (!rect->correction[plane]) {163 if (!rect->correction[plane]) {
164 int i,j;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 rect->correction[plane] = av_malloc_array(w, h * sizeof(**rect->correction));167 rect->correction[plane] = av_malloc_array(w, h * sizeof(**rect->correction));
168 if (!rect->correction[plane])168 if (!rect->correction[plane])
@@ -172,9 +172,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 3 unmodified lines
172 const int off_y2 = off_y * off_y;172 const int off_y2 = off_y * off_y;
173 for (i = 0; i < w; i++) {173 for (i = 0; i < w; i++) {
174 const int off_x = i - xcenter;174 const int off_x = i - xcenter;
175 const float r2 = (off_x * off_x + off_y2) * r2inv;175 const int64_t r2 = ((off_x * off_x + off_y2) * r2inv + (1LL<<31)) >> 32;
176 const float radius_mult = 1.0f + r2 * k1 + r2 * r2 * k2;176 const int64_t r4 = (r2 * r2 + (1<<27)) >> 28;
177 rect->correction[plane][j * w + i] = lrintf(radius_mult * (1<<24));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 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t