summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2019-09-22 20:52:40 +0200
committerPaul B Mahol <onemda@gmail.com>2019-09-22 22:32:37 +0200
commita8925d264a95c63c59faa94f697f51cb4dff09b4 (patch)
tree5899e4dc716cae92e08279fb063c41f40dab4c9c /libavfilter
parentb4d2bea64722cc0a9916a6265891f115551ad3e6 (diff)
avfilter/vf_v360: fix mercator_to_xyz()
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/vf_v360.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c
index c34e3258f5..3b3ca16578 100644
--- a/libavfilter/vf_v360.c
+++ b/libavfilter/vf_v360.c
@@ -1589,17 +1589,18 @@ static void mercator_to_xyz(const V360Context *s,
int i, int j, int width, int height,
float *vec)
{
- const float phi = ((2.f * i) / width - 1.f) * M_PI;
- const float theta = atanf(sinhf(((2.f * j) / height - 1.f) * 2.f * M_PI));
+ const float phi = ((2.f * i) / width - 1.f) * M_PI + M_PI_2;
+ const float y = ((2.f * j) / height - 1.f) * M_PI;
+ const float div = expf(2.f * y) + 1.f;
const float sin_phi = sinf(phi);
const float cos_phi = cosf(phi);
- const float sin_theta = sinf(theta);
- const float cos_theta = cosf(theta);
+ const float sin_theta = -2.f * expf(y) / div;
+ const float cos_theta = -(expf(2.f * y) - 1.f) / div;
- vec[0] = cos_theta * sin_phi;
- vec[1] = -sin_theta;
- vec[2] = -cos_theta * cos_phi;
+ vec[0] = sin_theta * cos_phi;
+ vec[1] = cos_theta;
+ vec[2] = sin_theta * sin_phi;
}
/**