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 52E3C462F9 for ; Thu, 11 May 2023 23:13:06 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7931068C160; Fri, 12 May 2023 02:12:58 +0300 (EEST) Received: from mail-oa1-f53.google.com (mail-oa1-f53.google.com [209.85.160.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6EC6D68C100 for ; Fri, 12 May 2023 02:12:50 +0300 (EEST) Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-18f4a6d2822so54090148fac.1 for ; Thu, 11 May 2023 16:12:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683846768; x=1686438768; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=TF5cPyKaLX0Aj15lRFTXWkQLBHc00sT4yivCoNRU+Rw=; b=Y0p4/gN8UiaSDdRrYijecmV82W9O4SXoeMPVTvnjQQWj6IH/4YFnawbyub0uQQhHvl JdYPcwupc9160AjVoRW3InwdyE+ZiLuA/Ds0UdAHFKFnQhDceXK1orF0vNDoLfYmURDS CgW6ClrhMpx4QHU9vzXXjPPaMFmEx6z8QTwhNt/xXuhRJhrn5chBmqyWxgla1Y20RQzI +C5vvY2fuPNup8OWrN0JYHz4OgDrB8f8IstbJhIA4TRIuw2z/O5OJjjWMWTO4d2uZAyM izeukwebv3yf5NIRawnxpVukD7D3U1VWuDx9yrcEwPH+TmETxmW5qBRPdVPKcb9Xcgvb jkUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683846768; x=1686438768; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TF5cPyKaLX0Aj15lRFTXWkQLBHc00sT4yivCoNRU+Rw=; b=KXkLI+EbgAvhDsnbnNhEOHwNVWg6TsLwoDNjYoNe/9oons+/xtp0dHOOjV1ZlYhSdP Du3N2ZtjArw78MR/ZfwiWDMspS6PCoSR7YBkxUY3h2MkABExYyOn5b2FHK9svK/roPBG WpoDnqJ4GUzeq7n8CLv9HagCfXva50KYN9Wg8fMJ0/TDAZrMMk/Vp4fmn2WfkWUETEeq bAQIQTSimJDwue2WToQBpFa9MsK7b4+PJJbHRRI1+Ac8igMIZJPotTilRLBcyqBtjzqO Z2uE4rP0CjWz9bI5zlkWmEteQkravkQTS0T4oV6CICeSEB+lU6IrbvZ4IQEPbFGA9qdw vqyA== X-Gm-Message-State: AC+VfDxJMygW/j2jBP4QLctvI4fmxE/t9l7tGERZN40YtYAy5bVzoYVQ D7BXzPUMKmKmWhsHvnal/u7EDZF4/cY= X-Google-Smtp-Source: ACHHUZ6Q9rxKUAHxHIU35v1FoUxQcskNXPt4TaDgTPK5VhjD0a4QW4+rf2pKpczxOVqJYG2lUY9nAg== X-Received: by 2002:a54:478e:0:b0:38e:d57:1979 with SMTP id o14-20020a54478e000000b0038e0d571979mr6430781oic.23.1683846768195; Thu, 11 May 2023 16:12:48 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id zf10-20020a0568716a8a00b001728669a604sm8528376oab.5.2023.05.11.16.12.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 May 2023 16:12:47 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 11 May 2023 20:12:30 -0300 Message-Id: <20230511231230.15668-2-jamrial@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230511231230.15668-1-jamrial@gmail.com> References: <20230511231230.15668-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avfilter/af_surround: replace double constants with float variants 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: This is cleaner than the approach in d1ded7310a. Signed-off-by: James Almer --- libavfilter/af_surround.c | 52 +++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/libavfilter/af_surround.c b/libavfilter/af_surround.c index bcc89053a4..4edd838101 100644 --- a/libavfilter/af_surround.c +++ b/libavfilter/af_surround.c @@ -330,16 +330,16 @@ static void angle_transform(float *x, float *y, float angle) if (angle == 90.f) return; - reference = angle * (float)M_PI / 180.f; + reference = angle * M_PIf / 180.f; r = hypotf(*x, *y); a = atan2f(*x, *y); r /= r_distance(a); - if (fabsf(a) <= (float)M_PI_4) - a *= reference / (float)M_PI_2; + if (fabsf(a) <= M_PI_4f) + a *= reference / M_PI_2f; else - a = (float)M_PI + (-2.f * (float)M_PI + reference) * ((float)M_PI - fabsf(a)) * FFDIFFSIGN(a, 0.f) / (3.f * (float)M_PI_2); + a = M_PIf + (-2.f * M_PIf + reference) * (M_PIf - fabsf(a)) * FFDIFFSIGN(a, 0.f) / (3.f * M_PI_2f); r *= r_distance(a); @@ -366,16 +366,16 @@ static void focus_transform(float *x, float *y, float focus) static void stereo_position(float a, float p, float *x, float *y) { av_assert2(a >= -1.f && a <= 1.f); - av_assert2(p >= 0.f && p <= (float)M_PI); - *x = av_clipf(a+a*fmaxf(0.f, p*p-(float)M_PI_2), -1.f, 1.f); - *y = av_clipf(cosf(a*(float)M_PI_2+(float)M_PI)*cosf((float)M_PI_2-p/(float)M_PI)*(float)M_LN10+1.f, -1.f, 1.f); + av_assert2(p >= 0.f && p <= M_PIf); + *x = av_clipf(a+a*fmaxf(0.f, p*p-M_PI_2f), -1.f, 1.f); + *y = av_clipf(cosf(a*M_PI_2f+M_PIf)*cosf(M_PI_2f-p/M_PIf)*M_LN10f+1.f, -1.f, 1.f); } static inline void get_lfe(int output_lfe, int n, float lowcut, float highcut, float *lfe_mag, float c_mag, float *mag_total, int lfe_mode) { if (output_lfe && n < highcut) { - *lfe_mag = n < lowcut ? 1.f : .5f*(1.f+cosf((float)M_PI*(lowcut-n)/(lowcut-highcut))); + *lfe_mag = n < lowcut ? 1.f : .5f*(1.f+cosf(M_PIf*(lowcut-n)/(lowcut-highcut))); *lfe_mag *= c_mag; if (lfe_mode) *mag_total -= *lfe_mag; @@ -777,8 +777,8 @@ static void filter_stereo(AVFilterContext *ctx) mag_sum = mag_sum < MIN_MAG_SUM ? 1.f : mag_sum; mag_dif = (l_mag - r_mag) / mag_sum; - if (phase_dif > (float)M_PI) - phase_dif = 2.f * (float)M_PI - phase_dif; + if (phase_dif > M_PIf) + phase_dif = 2.f * M_PIf - phase_dif; stereo_position(mag_dif, phase_dif, &x, &y); angle_transform(&x, &y, angle); @@ -832,8 +832,8 @@ static void filter_2_1(AVFilterContext *ctx) mag_sum = mag_sum < MIN_MAG_SUM ? 1.f : mag_sum; mag_dif = (l_mag - r_mag) / mag_sum; - if (phase_dif > (float)M_PI) - phase_dif = 2.f * (float)M_PI - phase_dif; + if (phase_dif > M_PIf) + phase_dif = 2.f * M_PIf - phase_dif; stereo_position(mag_dif, phase_dif, &x, &y); angle_transform(&x, &y, angle); @@ -889,8 +889,8 @@ static void filter_surround(AVFilterContext *ctx) mag_sum = mag_sum < MIN_MAG_SUM ? 1.f : mag_sum; mag_dif = (l_mag - r_mag) / mag_sum; - if (phase_dif > (float)M_PI) - phase_dif = 2.f * (float)M_PI - phase_dif; + if (phase_dif > M_PIf) + phase_dif = 2.f * M_PIf - phase_dif; stereo_position(mag_dif, phase_dif, &x, &y); angle_transform(&x, &y, angle); @@ -946,11 +946,11 @@ static void filter_5_0_side(AVFilterContext *ctx) float xl, yl; float xr, yr; - if (phase_difl > (float)M_PI) - phase_difl = 2.f * (float)M_PI - phase_difl; + if (phase_difl > M_PIf) + phase_difl = 2.f * M_PIf - phase_difl; - if (phase_difr > (float)M_PI) - phase_difr = 2.f * (float)M_PI - phase_difr; + if (phase_difr > M_PIf) + phase_difr = 2.f * M_PIf - phase_difr; stereo_position(mag_difl, phase_difl, &xl, &yl); stereo_position(mag_difr, phase_difr, &xr, &yr); @@ -1005,11 +1005,11 @@ static void filter_5_1_side(AVFilterContext *ctx) float xl, yl; float xr, yr; - if (phase_difl > (float)M_PI) - phase_difl = 2.f * (float)M_PI - phase_difl; + if (phase_difl > M_PIf) + phase_difl = 2.f * M_PIf - phase_difl; - if (phase_difr > (float)M_PI) - phase_difr = 2.f * (float)M_PI - phase_difr; + if (phase_difr > M_PIf) + phase_difr = 2.f * M_PIf - phase_difr; stereo_position(mag_difl, phase_difl, &xl, &yl); stereo_position(mag_difr, phase_difr, &xr, &yr); @@ -1064,11 +1064,11 @@ static void filter_5_1_back(AVFilterContext *ctx) float xl, yl; float xr, yr; - if (phase_difl > (float)M_PI) - phase_difl = 2.f * (float)M_PI - phase_difl; + if (phase_difl > M_PIf) + phase_difl = 2.f * M_PIf - phase_difl; - if (phase_difr > (float)M_PI) - phase_difr = 2.f * (float)M_PI - phase_difr; + if (phase_difr > M_PIf) + phase_difr = 2.f * M_PIf - phase_difr; stereo_position(mag_difl, phase_difl, &xl, &yl); stereo_position(mag_difr, phase_difr, &xr, &yr); -- 2.40.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".