[FFmpeg-cvslog] avfilter/vf_v360: improve sg output format

Paul B Mahol git at videolan.org
Thu Mar 26 15:15:38 EET 2020


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Thu Mar 26 13:37:13 2020 +0100| [7931e766ade210b3960aba987497d5bd2eeadcf4] | committer: Paul B Mahol

avfilter/vf_v360: improve sg output format

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

 libavfilter/vf_v360.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c
index fe0c9f3c4d..a16fd17574 100644
--- a/libavfilter/vf_v360.c
+++ b/libavfilter/vf_v360.c
@@ -1696,11 +1696,13 @@ static int stereographic_to_xyz(const V360Context *s,
 {
     const float x = ((2.f * i + 1.f) / width  - 1.f) * s->flat_range[0];
     const float y = ((2.f * j + 1.f) / height - 1.f) * s->flat_range[1];
-    const float xy = x * x + y * y;
+    const float r = hypotf(x, y);
+    const float theta = atanf(r) * 2.f;
+    const float sin_theta = sinf(theta);
 
-    vec[0] = 2.f * x / (1.f + xy);
-    vec[1] = (-1.f + xy) / (1.f + xy);
-    vec[2] = 2.f * y / (1.f + xy);
+    vec[0] =  x / r * sin_theta;
+    vec[1] = -y / r * sin_theta;
+    vec[2] = -cosf(theta);
 
     normalize_vector(vec);
 



More information about the ffmpeg-cvslog mailing list