Browse code

avfilter/vf_lenscorrection: get rid of some floats

Michael Niedermayer authored on 2014/08/20 20:19:26
Showing 1 changed files
... ...
@@ -56,9 +56,9 @@ AVFILTER_DEFINE_CLASS(lenscorrection);
56 56
 
57 57
 typedef struct ThreadData {
58 58
     AVFrame *in, *out;
59
-    float w, h;
59
+    int w, h;
60 60
     int plane;
61
-    float xcenter, ycenter;
61
+    int xcenter, ycenter;
62 62
     float k1, k2;
63 63
 } ThreadData;
64 64
 
... ...
@@ -68,9 +68,9 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
68 68
     AVFrame *in = td->in;
69 69
     AVFrame *out = td->out;
70 70
 
71
-    const float w = td->w, h = td->h;
72
-    const float xcenter = td->xcenter;
73
-    const float ycenter = td->ycenter;
71
+    const int w = td->w, h = td->h;
72
+    const int xcenter = td->xcenter;
73
+    const int ycenter = td->ycenter;
74 74
     const float r2inv = 4.0 / (w * w + h * h);
75 75
     const float k1 = td->k1;
76 76
     const float k2 = td->k2;
... ...
@@ -83,12 +83,12 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
83 83
     uint8_t *outrow = out->data[plane] + start * outlinesize;
84 84
     int i;
85 85
     for (i = start; i < end; i++, outrow += outlinesize) {
86
-        const float off_y = i - ycenter;
87
-        const float off_y2 = off_y * off_y;
86
+        const int off_y = i - ycenter;
87
+        const int off_y2 = off_y * off_y;
88 88
         uint8_t *out = outrow;
89 89
         int j;
90 90
         for (j = 0; j < w; j++) {
91
-            const float off_x = j - xcenter;
91
+            const int off_x = j - xcenter;
92 92
             const float r2 = (off_x * off_x + off_y2) * r2inv;
93 93
             const float radius_mult = 1.0f + r2 * k1 + r2 * r2 * k2;
94 94
             const int x = xcenter + radius_mult * off_x + 0.5f;
... ...
@@ -147,10 +147,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
147 147
     for (plane = 0; plane < rect->nb_planes; ++plane) {
148 148
         int hsub = plane == 1 || plane == 2 ? rect->hsub : 0;
149 149
         int vsub = plane == 1 || plane == 2 ? rect->vsub : 0;
150
-        float hdiv = 1 << hsub;
151
-        float vdiv = 1 << vsub;
152
-        float w = rect->width / hdiv;
153
-        float h = rect->height / vdiv;
150
+        int hdiv = 1 << hsub;
151
+        int vdiv = 1 << vsub;
152
+        int w = rect->width / hdiv;
153
+        int h = rect->height / vdiv;
154 154
         ThreadData td = {
155 155
             .in = in,
156 156
             .out  = out,