1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-15 14:13:16 +02:00

avfilter/vf_lenscorrection: get rid of some floats

This commit is contained in:
Michael Niedermayer
2014-08-20 13:19:26 +02:00
parent 50a35f0d2e
commit c1b663bc92

View File

@@ -56,9 +56,9 @@ AVFILTER_DEFINE_CLASS(lenscorrection);
typedef struct ThreadData { typedef struct ThreadData {
AVFrame *in, *out; AVFrame *in, *out;
float w, h; int w, h;
int plane; int plane;
float xcenter, ycenter; int xcenter, ycenter;
float k1, k2; float k1, k2;
} ThreadData; } ThreadData;
@@ -68,9 +68,9 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
AVFrame *in = td->in; AVFrame *in = td->in;
AVFrame *out = td->out; AVFrame *out = td->out;
const float w = td->w, h = td->h; const int w = td->w, h = td->h;
const float xcenter = td->xcenter; const int xcenter = td->xcenter;
const float ycenter = td->ycenter; const int ycenter = td->ycenter;
const float r2inv = 4.0 / (w * w + h * h); const float r2inv = 4.0 / (w * w + h * h);
const float k1 = td->k1; const float k1 = td->k1;
const float k2 = td->k2; const float k2 = td->k2;
@@ -83,12 +83,12 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
uint8_t *outrow = out->data[plane] + start * outlinesize; uint8_t *outrow = out->data[plane] + start * outlinesize;
int i; int i;
for (i = start; i < end; i++, outrow += outlinesize) { for (i = start; i < end; i++, outrow += outlinesize) {
const float off_y = i - ycenter; const int off_y = i - ycenter;
const float off_y2 = off_y * off_y; const int off_y2 = off_y * off_y;
uint8_t *out = outrow; uint8_t *out = outrow;
int j; int j;
for (j = 0; j < w; j++) { for (j = 0; j < w; j++) {
const float off_x = j - xcenter; const int off_x = j - xcenter;
const float r2 = (off_x * off_x + off_y2) * r2inv; const float r2 = (off_x * off_x + off_y2) * r2inv;
const float radius_mult = 1.0f + r2 * k1 + r2 * r2 * k2; const float radius_mult = 1.0f + r2 * k1 + r2 * r2 * k2;
const int x = xcenter + radius_mult * off_x + 0.5f; const int x = xcenter + radius_mult * off_x + 0.5f;
@@ -147,10 +147,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
for (plane = 0; plane < rect->nb_planes; ++plane) { for (plane = 0; plane < rect->nb_planes; ++plane) {
int hsub = plane == 1 || plane == 2 ? rect->hsub : 0; int hsub = plane == 1 || plane == 2 ? rect->hsub : 0;
int vsub = plane == 1 || plane == 2 ? rect->vsub : 0; int vsub = plane == 1 || plane == 2 ? rect->vsub : 0;
float hdiv = 1 << hsub; int hdiv = 1 << hsub;
float vdiv = 1 << vsub; int vdiv = 1 << vsub;
float w = rect->width / hdiv; int w = rect->width / hdiv;
float h = rect->height / vdiv; int h = rect->height / vdiv;
ThreadData td = { ThreadData td = {
.in = in, .in = in,
.out = out, .out = out,