From patchwork Tue Jul 13 08:29:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?6buE5a6H5pifKOWHjOaAgCk=?= X-Patchwork-Id: 28916 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5d:965a:0:0:0:0:0 with SMTP id d26csp4104573ios; Tue, 13 Jul 2021 01:29:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKyCx5EFJW43F8Fh+Dgss2czGapEftPGXoOVwfJ4SVx30K3XKmF5VvlhJYJGzX/ZNDK7Xf X-Received: by 2002:a05:6402:d5a:: with SMTP id ec26mr4253292edb.4.1626164967923; Tue, 13 Jul 2021 01:29:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626164967; cv=none; d=google.com; s=arc-20160816; b=nKk9AqlVnz8WqaSEu5DzTIvaSVWJXM6fjR5nJvM/9Y+yyhVDZ1XF5vlW3QTeJ/f9su mqdO/MvBAjp/0Q0Cd81HqeYklvy/KGywyI9JtqRII0SxxsUzsp71F6vgAyf3zdhrj8bA 1y1khJKyZrtW/990UzbP+7hQxNGYxoqKwcY+7vDeTB1jyGhFJe86f4xliCATlbJYKZoe 1sgg2GVmYH9s0hb/K52M94ALoD0y3xQA43/JI0seK2zFELwb/bXKZ+oXSPiVWdhW2tCU iRFdZoSSBexc10GwrzmiGwDHo8zxZapkMNTiqPlbgxxIul6GjHwuFu9DjKsEfJlOIrJW SrPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:to:from:date :dkim-signature:delivered-to; bh=qR94KtsGtsn35nONL8ZP2e916FatGw+oHk/GyMN3eWY=; b=c3yOrSFOCmnxFZEB8WPOZYoob9Yj2KkHHwNBhRDt8nRStlQXT7lvL5hZ+Ihx3Qhai0 DhiDW2sVL4YV9+wrIQ10IeU/CR0EKUvmZp0kRBLM9mf7ef4OIGNHqjq/cM4HeRAW3+fr eUpH2igUPSmTkye/JHab1xvCU05a+K2oJNPv12xeE7j4INuiSoXvBUOfnAYb0e+HrcJl QZe7fO+hiBx+l5RTc63/FpunQW9Shv2ZUmOlnhtB+mytJ0NlKxE4iouGKHQTBnZ7nu3W QzT8ZKkZ25u147GeeieRVSabapXDQWvO+UcqL2ho3Atsad1crtY2qSI5YVlW/bXAFP0M 7MTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@alibaba-inc.com header.s=default header.b=wmcIAzNh; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=alibaba-inc.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y15si5575319ejq.648.2021.07.13.01.29.27; Tue, 13 Jul 2021 01:29:27 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@alibaba-inc.com header.s=default header.b=wmcIAzNh; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=alibaba-inc.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C844168A976; Tue, 13 Jul 2021 11:29:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out0-147.mail.aliyun.com (out0-147.mail.aliyun.com [140.205.0.147]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5F79C68A7A4 for ; Tue, 13 Jul 2021 11:29:16 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alibaba-inc.com; s=default; t=1626164951; h=Date:From:To:Message-ID:Subject:MIME-Version:Content-Type; bh=W2QV5RTen4XD85zpmr0GDHN+NC9p+xqGo2zIV2L1ZOw=; b=wmcIAzNh0zx5uNf+Frvg2ioq7WgLRsQ+qhFo+O24NRs3b4fvoSYWLNdPiOLnHpMExHTgLBc+dl+XAQzlrvLhkPHvHTpZS81ql02F0E6OWN578JkBnQCpkopI4L/xFTVvKJ3JggqE1hHFLv/WJjPJLZrsj4dNmYYMa6EFPTgu92s= X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R101e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018047207; MF=huangyuxing.hyx@alibaba-inc.com; NM=1; PH=DW; RN=1; SR=0; TI=alimail_yun_mac.COREAPI357428f0679e4a8fa55b9a33b57422c4; Received: from WS-web (huangyuxing.hyx@alibaba-inc.com[alimail_yun_mac.COREAPI357428f0679e4a8fa55b9a33b57422c4]) by ay29a011140100202.et135 at Tue, 13 Jul 2021 16:29:10 +0800 Date: Tue, 13 Jul 2021 16:29:10 +0800 From: " =?utf-8?b?6buE5a6H5pifKOWHjOaAgCk=?= " To: "ffmpeg-devel@ffmpeg.org" Message-ID: <2372164d-7c0b-4b19-9ee4-7755f762e74f.huangyuxing.hyx@alibaba-inc.com> X-Priority: 3 X-Mailer: [Alimail-Mailagent revision 2546561] MIME-Version: 1.0 x-aliyun-comment: CT_47 X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [FFmpeg-devel] =?utf-8?q?=5BPATCH=5D_lavfi/vf=5Fv360=3A_add_missing?= =?utf-8?q?_0=2E5_subpixel_shift?= X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ovpyprYucmUU Signed-off-by: 凌怀 --- libavfilter/vf_v360.c | 49 ++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 14 deletions(-) const float phi = atan2f(vec[0], vec[2]); const float theta = asinf(vec[1]); - const float uf = (phi / s->iflat_range[0] + 1.f) * width / 2.f; - const float vf = (theta / s->iflat_range[1] + 1.f) * height / 2.f; + const float uf = (phi / s->iflat_range[0] + 1.f) * width / 2.f - 0.5f; + const float vf = (theta / s->iflat_range[1] + 1.f) * height / 2.f - 0.5f; const int ui = floorf(uf); const int vi = floorf(vf); @@ -2866,7 +2866,7 @@ 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 uf = s->flat_range[0] * ((2.f * i + 1.f) / width - 1.f); const float vf = s->flat_range[1] * ((2.f * j + 1.f) / height - 1.f); const float phi = atan2f(vf, uf); @@ -2932,6 +2932,9 @@ static int xyz_to_fisheye(const V360Context *s, uf = (uf + 0.5f) * width; vf = (vf + 0.5f) * height; + uf -= 0.5f; + vf -= 0.5f; + ui = floorf(uf); vi = floorf(vf); @@ -3007,8 +3010,8 @@ static int xyz_to_pannini(const V360Context *s, const float x = S * sinf(phi); const float y = S * tanf(theta); - const float uf = (x + 1.f) * width / 2.f; - const float vf = (y + 1.f) * height / 2.f; + const float uf = (x + 1.f) * width / 2.f - 0.5f; + const float vf = (y + 1.f) * height / 2.f - 0.5f; const int ui = floorf(uf); const int vi = floorf(vf); @@ -3115,8 +3118,8 @@ static int xyz_to_cylindrical(const V360Context *s, const float phi = atan2f(vec[0], vec[2]) / s->iflat_range[0]; const float theta = asinf(vec[1]); - const float uf = (phi + 1.f) * (width - 1) / 2.f; - const float vf = (tanf(theta) / s->iflat_range[1] + 1.f) * height / 2.f; + const float uf = (phi + 1.f) * (width - 1) / 2.f - 0.5f; + const float vf = (tanf(theta) / s->iflat_range[1] + 1.f) * height / 2.f - 0.5f; const int ui = floorf(uf); const int vi = floorf(vf); @@ -3225,8 +3228,8 @@ static int xyz_to_cylindricalea(const V360Context *s, const float phi = atan2f(vec[0], vec[2]) / s->iflat_range[0]; const float theta = asinf(vec[1]); - const float uf = (phi + 1.f) * (width - 1) / 2.f; - const float vf = (sinf(theta) / s->iflat_range[1] + 1.f) * height / 2.f; + const float uf = (phi + 1.f) * (width - 1) / 2.f - 0.5f; + const float vf = (sinf(theta) / s->iflat_range[1] + 1.f) * height / 2.f - 0.5f; const int ui = floorf(uf); const int vi = floorf(vf); @@ -3361,6 +3364,9 @@ static int xyz_to_tetrahedron(const V360Context *s, uf *= width; vf *= height; + uf -= 0.5f; + vf -= 0.5f; + ui = floorf(uf); vi = floorf(vf); @@ -3397,7 +3403,7 @@ static int dfisheye_to_xyz(const V360Context *s, const int ei = i >= ew ? i - ew : i; const float m = i >= ew ? 1.f : -1.f; - const float uf = s->flat_range[0] * ((2.f * ei) / ew - 1.f); + const float uf = s->flat_range[0] * ((2.f * ei + 1.f) / ew - 1.f); const float vf = s->flat_range[1] * ((2.f * j + 1.f) / eh - 1.f); const float h = hypotf(uf, vf); @@ -3452,6 +3458,9 @@ static int xyz_to_dfisheye(const V360Context *s, uf = ew - uf; } + uf -= 0.5f; + vf -= 0.5f; + ui = floorf(uf); vi = floorf(vf); @@ -3491,8 +3500,8 @@ static int barrel_to_xyz(const V360Context *s, const int ew = 4 * width / 5; const int eh = height; - const float phi = ((2.f * i) / ew - 1.f) * M_PI / scale; - const float theta = ((2.f * j) / eh - 1.f) * theta_range / scale; + const float phi = ((2.f * i + 1.f) / ew - 1.f) * M_PI / scale; + const float theta = ((2.f * j + 1.f) / eh - 1.f) * theta_range / scale; const float sin_phi = sinf(phi); const float cos_phi = cosf(phi); @@ -3596,6 +3605,9 @@ static int xyz_to_barrel(const V360Context *s, vf = 0.5f * eh * (vf * scale + 1.f); } + uf -= 0.5f; + vf -= 0.5f; + ui = floorf(uf); vi = floorf(vf); @@ -3692,6 +3704,9 @@ static int xyz_to_barrelsplit(const V360Context *s, vf = height * 0.25f * (vf * scaleh + 1.f) + v_offset; } + uf -= 0.5f; + vf -= 0.5f; + ui = floorf(uf); vi = floorf(vf); @@ -3910,6 +3925,9 @@ static int xyz_to_tspyramid(const V360Context *s, uf *= width; vf *= height; + uf -= 0.5f; + vf -= 0.5f; + ui = floorf(uf); vi = floorf(vf); @@ -3995,6 +4013,9 @@ static int xyz_to_octahedron(const V360Context *s, uf *= width; vf *= height; + uf -= 0.5f; + vf -= 0.5f; + ui = floorf(uf); vi = floorf(vf); diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c index 0c47883d4d..c0dafe6bbe 100644 --- a/libavfilter/vf_v360.c +++ b/libavfilter/vf_v360.c @@ -1790,8 +1790,8 @@ static int hequirect_to_xyz(const V360Context *s, int i, int j, int width, int height, float *vec) { - const float phi = ((2.f * i + 0.5f) / width - 1.f) * M_PI_2; - const float theta = ((2.f * j + 0.5f) / height - 1.f) * M_PI_2; + const float phi = ((2.f * i + 1.0f) / width - 1.f) * M_PI_2; + const float theta = ((2.f * j + 1.0f) / height - 1.f) * M_PI_2; const float sin_phi = sinf(phi); const float cos_phi = cosf(phi); @@ -2158,8 +2158,8 @@ static int xyz_to_equirect(const V360Context *s,