From patchwork Sun Mar 21 12:44:14 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: 26519 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 BC56D4499F7 for ; Sun, 21 Mar 2021 14:45:23 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9DF8668A8FA; Sun, 21 Mar 2021 14:45:23 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 83AE2680831 for ; Sun, 21 Mar 2021 14:45:17 +0200 (EET) Received: by mail-pf1-f173.google.com with SMTP id x126so9121483pfc.13 for ; Sun, 21 Mar 2021 05:45:17 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=BD5xoeK80AeVOnb2skcL1DvgZpyi65gEyJJCmB7X9QA=; b=rkhnSovPvYI/Hmc3x0YMMja+Q67VPnSK8IoyJjtksos8MD78f1fZCzBC1PjG8gNubt ldEtzBXlOSJg82uN0z+fCEUCdQsz/RcTLYhGIuolriqsKQr75zhFFZpr9yhIG+74RDLb JPqaEhedL9IoHS6CRb10O2WSHXdHoZ+NcDxPnjIVHNNn1C5sV+wCeHL+zowAz+8zyhrB 4yW0GE0Hxpch5evhBG9WOBrbSib+uWej0fWQZtW4EvaLxpyRQJ2wsHmx04eUfpaBIoQO 3D4WLaGoRJfblcflxXmffOGlHOrZJLjAlmgoEx1m1LIAsVTJMfrTKYdzYx2mV7GT6QGN 4agA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=BD5xoeK80AeVOnb2skcL1DvgZpyi65gEyJJCmB7X9QA=; b=F+afYcuYzoS19OXSlJBIW4diR8CkVE4OJtb7auGW24yIVRrVF0ymKHXKfsffq+mQvc TaLIcuL13L4nd2UyBdMNi+GjqcumXXM1T8oUduweim7ALG1y+wqh/a0uNvSbewsdcqG6 dF15vun4XBjZHa4bQZ5AXAwcPmcYdigYdYKFRWU9S1PcqnsgwCko8keKlVX0M6jCEE/f LKB8yXXh7nB4/BcPzrE86ru89fztISYO29WhpLCtVV4z9Zaho7APHvgfz5nxNC9HpAOg wbLoi92X8qXI5GB9Hajr3uxWAokKqWYzKRnMlRE0Vx+W0likeTqBr5rIK424Niq5mJTc s4Sw== X-Gm-Message-State: AOAM532x6/Zq2jx8ZvbmXiDigo27uOP2FhQ7dIr4tFo+WveIuc5JpBTz yHUoBmPWCBCSOcJLIYE+Gwvmd6o7L8+RGA== X-Google-Smtp-Source: ABdhPJxPOGZTSmqfR1Y6Mkt1I7ULqwUYvrIuJs8U+E9LeKYt6/OIp551VPMCfjOrji7eEjPWRGssBQ== X-Received: by 2002:a63:e416:: with SMTP id a22mr19571978pgi.128.1616330715627; Sun, 21 Mar 2021 05:45:15 -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 x11sm13334158pjh.0.2021.03.21.05.45.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Mar 2021 05:45:15 -0700 (PDT) From: Daniel Playfair Cal To: ffmpeg-devel@ffmpeg.org Date: Sun, 21 Mar 2021 23:44:14 +1100 Message-Id: <20210321124414.1223626-4-daniel.playfair.cal@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210321124414.1223626-1-daniel.playfair.cal@gmail.com> References: <20210321124414.1223626-1-daniel.playfair.cal@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] avfilter/vf_v360: refactor (i)flat_range for fisheye 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 to match their meaning for the flat/rectilinear projection. That is, the range is between the two x or two y coordinates of the outermost points above/below or left/right of the center, in the flat/rectilinear 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 68bb2f7b0f..3158451963 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 = -0.5f < uf && uf < 0.5f && -0.5f < vf && vf < 0.5f; int ui, vi;