]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/vf_v360: partialy revert previous commit
authorPaul B Mahol <onemda@gmail.com>
Mon, 9 Sep 2019 15:43:16 +0000 (17:43 +0200)
committerPaul B Mahol <onemda@gmail.com>
Mon, 9 Sep 2019 15:47:03 +0000 (17:47 +0200)
roll/pitch can do exactly same thing.

doc/filters.texi
libavfilter/v360.h
libavfilter/vf_v360.c

index d1d47be4150e5ef6c89afe49da23b39006675211..004b859ea06fa08b369fe7deb1f83040dffd97dc 100644 (file)
@@ -18040,10 +18040,6 @@ Format specific options:
 @item h_fov
 @item v_fov
 Set horizontal/vertical field of view. Values in degrees.
-
-@item p_lon
-@item p_lat
-Set central point of projection longitude/latitude. Values in degrees.
 @end table
 
 @end table
index b769218c04242a71745e2a7c73439c76028fa714..93ac8034ef9235d2f932e03f6a3d68656b401a17 100644 (file)
@@ -105,7 +105,6 @@ typedef struct V360Context {
 
     float h_fov, v_fov;
     float flat_range[3];
-    float p_lon, p_lat;
 
     float input_mirror_modifier[2];
 
index 0ea7a460ea4f9bea23c0655c09ad04dd5a81a151..4d59316bf6bdc276df861497d75b00bb05e80e8e 100644 (file)
@@ -33,8 +33,6 @@
  * 5) Remap input frame to output frame using precalculated data
  */
 
-#include <float.h>
-
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/pixdesc.h"
@@ -107,8 +105,6 @@ static const AVOption v360_options[] = {
     {   "iv_flip", "flip in video vertically",     OFFSET(iv_flip), AV_OPT_TYPE_BOOL,   {.i64=0},               0,                   1, FLAGS, "iv_flip"},
     {  "in_trans", "transpose video input",   OFFSET(in_transpose), AV_OPT_TYPE_BOOL,   {.i64=0},               0,                   1, FLAGS, "in_transpose"},
     { "out_trans", "transpose video output", OFFSET(out_transpose), AV_OPT_TYPE_BOOL,   {.i64=0},               0,                   1, FLAGS, "out_transpose"},
-    {     "p_lon", "central projection longitude",   OFFSET(p_lon), AV_OPT_TYPE_FLOAT,  {.dbl=0.f},        -180.f,               180.f, FLAGS, "p_lon"},
-    {     "p_lat", "central projection latitude",    OFFSET(p_lat), AV_OPT_TYPE_FLOAT,  {.dbl=90.f},        -90.f,                90.f, FLAGS, "p_lat"},
     { NULL }
 };
 
@@ -1412,24 +1408,11 @@ static void stereographic_to_xyz(const V360Context *s,
 {
     const float x = ((2.f * i) / width  - 1.f) * (s->h_fov / 180.f) * M_PI;
     const float y = ((2.f * j) / height - 1.f) * (s->v_fov /  90.f) * M_PI_2;
-    const float rho = hypotf(x, y) + FLT_EPSILON;
-    const float c = 2.f * atan2f(rho, 0.15f / 2.f);
-    const float cos_c = cosf(c);
-    const float sin_c = sinf(c);
-    const float cp_x = s->p_lon / 180.f * M_PI;
-    const float cp_y = s->p_lat / 90.f * M_PI_2;
-
-    const float phi   = cp_x + atan2f(x * sin_c, rho * cosf(cp_y) * cos_c - y * sinf(cp_y) * sin_c);
-    const float theta = asinf(cos_c * sinf(cp_y) + (y * sin_c * cosf(cp_y)) / rho);
-
-    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 xy = x * x + y * y;
 
-    vec[0] =  cos_theta * sin_phi;
-    vec[1] = -sin_theta;
-    vec[2] = -cos_theta * cos_phi;
+    vec[0] = 2.f * x / (1.f + xy);
+    vec[1] = (-1.f + xy) / (1.f + xy);
+    vec[2] = 2.f * y / (1.f + xy);
 
     normalize_vector(vec);
 }