summaryrefslogtreecommitdiff
path: root/libavfilter/vf_v360.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2019-09-21 16:07:16 +0200
committerPaul B Mahol <onemda@gmail.com>2019-09-21 16:31:32 +0200
commitecaef69fbb1ed011a14624d944113e32a17d7780 (patch)
treec355c3cfc120fbaf034df56e1de2f1134fd131b2 /libavfilter/vf_v360.c
parentb8dfc108a22501fc7b07cf1c1835d3d9e576398a (diff)
avfilter/vf_v360: simplify xyz_to_ball() calculations
Diffstat (limited to 'libavfilter/vf_v360.c')
-rw-r--r--libavfilter/vf_v360.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c
index d966723770..1a0fe90909 100644
--- a/libavfilter/vf_v360.c
+++ b/libavfilter/vf_v360.c
@@ -1603,12 +1603,13 @@ static void xyz_to_ball(const V360Context *s,
uint16_t us[4][4], uint16_t vs[4][4], float *du, float *dv)
{
const float l = hypotf(vec[0], vec[1]);
- const float r = sinf(acosf(-vec[2]) * 0.5f);
+ const float r = sqrtf(1.f + vec[2]) / M_SQRT2;
float uf, vf;
int ui, vi;
- uf = (1.f - r * vec[0] * s->input_mirror_modifier[0] / l) * width / 2.f;
- vf = (1.f + r * vec[1] * s->input_mirror_modifier[1] / l) * height / 2.f;
+ uf = (1.f + r * vec[0] * s->input_mirror_modifier[0] / (l > 0.f ? l : 1.f)) * width * 0.5f;
+ vf = (1.f - r * vec[1] * s->input_mirror_modifier[1] / (l > 0.f ? l : 1.f)) * height * 0.5f;
+
ui = floorf(uf);
vi = floorf(vf);