From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id A907541223 for ; Thu, 19 May 2022 13:48:07 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E3A5968B4AC; Thu, 19 May 2022 16:47:46 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3393E689F59 for ; Thu, 19 May 2022 16:47:39 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id BA32424017C for ; Thu, 19 May 2022 15:47:38 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 6mA6m6-PgpyS for ; Thu, 19 May 2022 15:47:38 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 9569924017E for ; Thu, 19 May 2022 15:47:36 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 6E5803A06EC; Thu, 19 May 2022 15:47:36 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 19 May 2022 15:47:27 +0200 Message-Id: <20220519134728.15354-3-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220519134728.15354-1-anton@khirnov.net> References: <20220519134728.15354-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/4] lavfi/vf_v360: fix barrelsplit transform with padding 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Make it match Facebook's transform360 (https://github.com/facebook/transform360) Fixes one part of #9725. --- libavfilter/vf_v360.c | 46 ++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c index 620a995733..940e6fc5f6 100644 --- a/libavfilter/vf_v360.c +++ b/libavfilter/vf_v360.c @@ -3683,30 +3683,33 @@ static int xyz_to_barrelsplit(const V360Context *s, u_shift = 2 * ew; + uf = vec[0] / vec[1] * scalew; + vf = vec[2] / vec[1] * scaleh; + if (theta <= 0.f && theta >= -M_PI_2 && phi <= M_PI_2 && phi >= -M_PI_2) { - uf = -vec[0] / vec[1]; - vf = -vec[2] / vec[1]; + uf *= -1.0f; + vf = -(vf + 1.f) * scaleh + 1.f; v_shift = 0; v_offset = -eh; } else if (theta >= 0.f && theta <= M_PI_2 && phi <= M_PI_2 && phi >= -M_PI_2) { - uf = vec[0] / vec[1]; - vf = -vec[2] / vec[1]; + vf = -(vf - 1.f) * scaleh; v_shift = height * 0.25f; } else if (theta <= 0.f && theta >= -M_PI_2) { - uf = vec[0] / vec[1]; - vf = vec[2] / vec[1]; + // back top + vf = (vf - 1.f) * scaleh + 1.f; v_shift = height * 0.5f; v_offset = -eh; } else { - uf = -vec[0] / vec[1]; - vf = vec[2] / vec[1]; + // back bottom + uf *= -1.0f; + vf = (vf + 1.f) * scaleh; v_shift = height * 0.75f; } - uf = 0.5f * width / 3.f * (uf * scalew + 1.f); - vf = height * 0.25f * (vf * scaleh + 1.f) + v_offset; + uf = 0.5f * width / 3.f * (uf + 1.f); + vf *= height * 0.25f; } ui = floorf(uf); @@ -3764,29 +3767,22 @@ static int barrelsplit_to_xyz(const V360Context *s, const float scalew = s->fout_pad > 0 ? 1.f - s->fout_pad / (width / 3.f) : 1.f - s->out_pad; const float scaleh = s->fout_pad > 0 ? 1.f - s->fout_pad / (height / 4.f) : 1.f - s->out_pad; - const int face = floorf(y * 4.f); + const float facef = floorf(y * 4.f); + const int face = facef; const float dir_vert = (face == 1 || face == 3) ? 1.0f : -1.0f; float uf, vf; uf = x * 3.f - 2.f; switch (face) { - case 0: - vf = y * 2.f; + case 0: // front top + case 1: // front bottom uf = 1.f - uf; - vf = 0.5f - vf; - break; - case 1: - vf = y * 2.f; - uf = 1.f - uf; - vf = 1.f - (vf - 0.5f); - break; - case 2: - vf = y * 2.f - 0.5f; - vf = 1.f - (1.f - vf); + vf = (0.5f - 2.f * y) / scaleh + facef; break; - case 3: - vf = y * 2.f - 1.5f; + case 2: // back top + case 3: // back bottom + vf = (y * 2.f - 1.5f) / scaleh + 3.f - facef; break; } l_x = (0.5f - uf) / scalew; -- 2.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".