[FFmpeg-devel] [PATCH] vf_v360: fix (i)flat_range for fisheye projection
Paul B Mahol
onemda at gmail.com
Sun Mar 21 11:14:41 EET 2021
Please make log message consistent with other commits to this file.
Also make set of patches to be applied all at once instead each single one.
On Fri, Mar 19, 2021 at 1:08 PM Daniel Playfair Cal <
daniel.playfair.cal at gmail.com> wrote:
> This changes the iflat_range and flat_range values for the fisheye
> projection so that they indicate the maximum angle between an observed
> point and the center (direction the camera is facing). This matches the
> meaning of those variables in the flat projection.
>
> Signed-off-by: Daniel Playfair Cal <daniel.playfair.cal at gmail.com>
> ---
>
> Sorry for the previous identical patch, this version really does remove
> the use of double literals.
>
> libavfilter/vf_v360.c | 19 +++++++++----------
> 1 file changed, 9 insertions(+), 10 deletions(-)
>
> diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c
> index 94473cd5b3..7535612d34 100644
> --- a/libavfilter/vf_v360.c
> +++ b/libavfilter/vf_v360.c
> @@ -2807,9 +2807,8 @@ static int prepare_fisheye_out(AVFilterContext *ctx)
> {
> V360Context *s = ctx->priv;
>
> - s->flat_range[0] = s->h_fov / 180.f;
> - s->flat_range[1] = s->v_fov / 180.f;
> -
> + s->flat_range[0] = 0.5f * s->h_fov * M_PI / 180.f;
> + s->flat_range[1] = 0.5f * s->v_fov * M_PI / 180.f;
> return 0;
> }
>
> @@ -2827,8 +2826,8 @@ static int fisheye_to_xyz(const V360Context *s,
> int i, int j, int width, int height,
> float *vec)
> {
> - const float uf = s->flat_range[0] * ((2.f * i) / width - 1.f);
> - const float vf = s->flat_range[1] * ((2.f * j + 1.f) / height - 1.f);
> + const float uf = 2.f * s->flat_range[0] / M_PI * ((2.f * i) / width
> - 1.f);
> + const float vf = 2.f * s->flat_range[1] / M_PI * ((2.f * j + 1.f) /
> height - 1.f);
>
> const float phi = atan2f(vf, uf);
> const float theta = M_PI_2 * (1.f - hypotf(uf, vf));
> @@ -2858,8 +2857,8 @@ static int prepare_fisheye_in(AVFilterContext *ctx)
> {
> V360Context *s = ctx->priv;
>
> - s->iflat_range[0] = s->ih_fov / 180.f;
> - s->iflat_range[1] = s->iv_fov / 180.f;
> + s->iflat_range[0] = 0.5f * s->ih_fov * M_PI / 180.f;
> + s->iflat_range[1] = 0.5f * s->iv_fov * M_PI / 180.f;
>
> return 0;
> }
> @@ -2882,10 +2881,10 @@ static int xyz_to_fisheye(const V360Context *s,
> {
> const float h = hypotf(vec[0], vec[1]);
> const float lh = h > 0.f ? h : 1.f;
> - const float phi = atan2f(h, vec[2]) / M_PI;
> + const float phi = atan2f(h, vec[2]);
>
> - float uf = vec[0] / lh * phi / s->iflat_range[0];
> - float vf = vec[1] / lh * phi / s->iflat_range[1];
> + float uf = 0.5f * vec[0] / lh * phi / s->iflat_range[0];
> + float vf = 0.5f * vec[1] / lh * phi / s->iflat_range[1];
>
> const int visible = hypotf(uf, vf) <= 0.5f;
> int ui, vi;
> --
> 2.31.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-devel
mailing list