summaryrefslogtreecommitdiff
path: root/libavfilter/vf_v360.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2019-09-21 21:33:03 +0200
committerPaul B Mahol <onemda@gmail.com>2019-09-21 21:33:03 +0200
commit073d22696e3e1afda3c2cc786a94caadb30d5b5f (patch)
treeceb75c3d91e3f46b3083cf96f7b536e88992b83e /libavfilter/vf_v360.c
parentb342678bc47b4e502642e11b05215ed4bc554c33 (diff)
avfilter/vf_v360: simplify xyz_to_dfisheye() calculations
Diffstat (limited to 'libavfilter/vf_v360.c')
-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 741a626bc8..fbaa1c4f89 100644
--- a/libavfilter/vf_v360.c
+++ b/libavfilter/vf_v360.c
@@ -2083,11 +2083,12 @@ static void xyz_to_dfisheye(const V360Context *s,
const float ew = width / 2.f;
const float eh = height;
- const float phi = atan2f(-vec[1], -vec[0]) * s->input_mirror_modifier[0];
- const float theta = acosf(fabsf(vec[2])) / M_PI * s->input_mirror_modifier[1];
+ const float h = hypotf(vec[0], vec[1]);
+ const float lh = h > 0.f ? h : 1.f;
+ const float theta = acosf(fabsf(vec[2])) / M_PI;
- float uf = (theta * cosf(phi) * scale + 0.5f) * ew;
- float vf = (theta * sinf(phi) * scale + 0.5f) * eh;
+ float uf = (theta * (-vec[0] / lh) * s->input_mirror_modifier[0] * scale + 0.5f) * ew;
+ float vf = (theta * (-vec[1] / lh) * s->input_mirror_modifier[1] * scale + 0.5f) * eh;
int ui, vi;
int u_shift;