From patchwork Fri Mar 19 09:47:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Playfair Cal X-Patchwork-Id: 26483 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 5F3A5449D11 for ; Fri, 19 Mar 2021 11:47:18 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4398868A59A; Fri, 19 Mar 2021 11:47:18 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A600F688174 for ; Fri, 19 Mar 2021 11:47:11 +0200 (EET) Received: by mail-pf1-f179.google.com with SMTP id c204so5502434pfc.4 for ; Fri, 19 Mar 2021 02:47:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0DGFWapnm5D7uK0M5pGT4LVlQPHszPnHCBkl+Ofeo6w=; b=S2evgd973tmE2qc8JBrPrZTBrqOyMbWAUGPnqPX6RA+XGVXqiDCG0sFhcOiiRPKvLb PU7uLYQf0qRPA9VmhoVJqMWvcKEHh74dEkLfUZyyV7uVNo29cETCt0ApTfBeHEGWII8Z xCqn5FCdXSnMdhVWOrhHprwqiu4oy38LHegwGMuUU8SevGes5oAm24WACE+kybfDMdoK Za3pDi+6ll15dowvM8oDLCWfg+qa/OgWyxSmjJoytOAUR0ZFeR9uYTTbgAj38buN5/9q NjjDOOGTNRuCTcpsux0F4C8C2LA88cmVOAGFqoefVtf3XC48Crk8lEw/2XRBQBO0qXcE aRNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0DGFWapnm5D7uK0M5pGT4LVlQPHszPnHCBkl+Ofeo6w=; b=Pc7igABc7X4XPvZApnDDd09aJmz8rolm3Z25g5amQxhaoZ+DLwSS5wjPx08eIB+xfZ T5sjMJz76CEdqdTjVexBvUpJAEpp7dWhoX6onhN0Zg/J2QqcV0xePwOvXATvIv1KIo42 9UFl/K/NP/tQc2lDCuiCj77QwgkY2C4pm9Z1shFGA0MCI/+voBMUUoE+3x9D2hCdNDse uAeinnwlgeKdiJfpAkQbwDMcDxWZMKtjGBLFVxoWBojRpd02JEGuPDdzLAjVF1lzFXxf zY/0bkDOCzLonGLlplsGsJBf5wgR0lNqOZ/lLzNl38BBKQ/9FTgFHG6VG3KQvvbmWkez JYbQ== X-Gm-Message-State: AOAM533aY/zbp7EA7mk8dPky2hZ6w/NSj03NlHQOz+U1eLpZF6oKnh8/ ToHfEViesJdYceVzeFAm0bFPJs0l+enLbw== X-Google-Smtp-Source: ABdhPJwXixnvDV9pGdukJ2fDFbA0re+64nvYRA1LnxjaVIKjIF4avyflnBp3ZIuTytcDFagoX+pwtQ== X-Received: by 2002:a62:f244:0:b029:1f8:40aa:8d64 with SMTP id y4-20020a62f2440000b02901f840aa8d64mr8241345pfl.81.1616147229949; Fri, 19 Mar 2021 02:47:09 -0700 (PDT) Received: from localhost.localdomain (110-175-121-4.static.tpgi.com.au. [110.175.121.4]) by smtp.gmail.com with ESMTPSA id y7sm5082983pfq.70.2021.03.19.02.47.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 02:47:09 -0700 (PDT) From: Daniel Playfair Cal To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Mar 2021 20:47:02 +1100 Message-Id: <20210319094702.927472-1-daniel.playfair.cal@gmail.com> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] vf_v360: fix (i)flat_range for fisheye projection X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Daniel Playfair Cal Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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 --- 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..d4f0836937 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.5 * s->h_fov * M_PI / 180.f; + s->flat_range[1] = 0.5 * 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.5 * s->ih_fov * M_PI / 180.f; + s->iflat_range[1] = 0.5 * 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;