summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2020-02-29 16:39:35 +0100
committerPaul B Mahol <onemda@gmail.com>2020-02-29 16:39:35 +0100
commit3733a6bc20e2a2ca7b06f5d867542f1f5cc874f1 (patch)
treecbf3951fae441d1b2bf30fa4794e5bb5375ddda6 /libavfilter
parent2dfd9445ff9b69a2b826e7b4c21c316689000147 (diff)
downloadffmpeg-3733a6bc20e2a2ca7b06f5d867542f1f5cc874f1.tar.gz
avfilter/vf_v360: speed up fisheye input calculation
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/vf_v360.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c
index 90e45b4fd0..3c73ad32f7 100644
--- a/libavfilter/vf_v360.c
+++ b/libavfilter/vf_v360.c
@@ -2484,11 +2484,12 @@ static int xyz_to_fisheye(const V360Context *s,
const float *vec, int width, int height,
int16_t us[4][4], int16_t vs[4][4], float *du, float *dv)
{
- const float phi = -atan2f(hypotf(vec[0], vec[1]), -vec[2]) / M_PI;
- const float theta = -atan2f(vec[0], vec[1]);
+ const float h = hypotf(vec[0], vec[1]);
+ const float lh = h > 0.f ? h : 1.f;
+ const float phi = atan2f(h, -vec[2]) / M_PI;
- float uf = sinf(theta) * phi * s->input_mirror_modifier[0] / s->iflat_range[0];
- float vf = cosf(theta) * phi * s->input_mirror_modifier[1] / s->iflat_range[1];
+ float uf = vec[0] / lh * phi * s->input_mirror_modifier[0] / s->iflat_range[0];
+ float vf = -vec[1] / lh * phi * s->input_mirror_modifier[1] / s->iflat_range[1];
const int visible = hypotf(uf, vf) <= 0.5f;
int ui, vi;