[FFmpeg-cvslog] avfilter/vf_v360: simplify xyz_to_ball() calculations

Paul B Mahol git at videolan.org
Sat Sep 21 17:36:51 EEST 2019


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sat Sep 21 16:07:16 2019 +0200| [ecaef69fbb1ed011a14624d944113e32a17d7780] | committer: Paul B Mahol

avfilter/vf_v360: simplify xyz_to_ball() calculations

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ecaef69fbb1ed011a14624d944113e32a17d7780
---

 libavfilter/vf_v360.c | 7 ++++---
 1 file 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);
 



More information about the ffmpeg-cvslog mailing list