From patchwork Sun Jan 29 12:53:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 2356 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp1035978vsb; Sun, 29 Jan 2017 04:53:57 -0800 (PST) X-Received: by 10.223.145.227 with SMTP id 90mr15089608wri.156.1485694437560; Sun, 29 Jan 2017 04:53:57 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q4si12726343wrc.328.2017.01.29.04.53.57; Sun, 29 Jan 2017 04:53:57 -0800 (PST) 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=@gmail.com; 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=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9880468A322; Sun, 29 Jan 2017 14:53:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5BA1F68A200 for ; Sun, 29 Jan 2017 14:53:46 +0200 (EET) Received: by mail-wm0-f68.google.com with SMTP id u63so2103227wmu.2 for ; Sun, 29 Jan 2017 04:53:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=ft17wS1USrRgVtevaAabvWhcVEWOKc//N+563H1x4DY=; b=oJ8nsx9spuhEnpZF89gmN0gBYjUw04sduCWZXMXMKrcDXvBHlXtFDpNuVaE1QRwP+O 6vrEn43HZfFgbioJ5d8PPj9GsqMIYFHJ1+t8rTSk9mXhB5mXu8svWBdTDootBISWq/FX 24xNQA6rXOwQFdBUtBmR6jnIeGDJwEPOahcHFdrX6J7AVO08WZ50z8S77r+pAY3Bbur9 znFeoQZhivl4WlSAJ+xrb3dNQIXjk+RMWphcmVtdIjIdkRHSTXtdB/Djzrs+yM5153/c Mwn5VG5RhPPw2XuezUpG6/kxqgDlV2myaoYLE4/0BeR3MI2N5Bkg3tC9rkUjRcuYgEy5 H10g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=ft17wS1USrRgVtevaAabvWhcVEWOKc//N+563H1x4DY=; b=BrLvKU8OW/N1mDLUxNi3DjTTpDJ3D7tjXpQEjV9OWQznEc/EYiNPmsPHvieG+T6vwi 6ruUa189Rt/t87Au2pbbPIQ1mkrbt68c/oBqUDtCiVJ9QAf/Gi0IqSKJMJ//jlOVCmAg c1I5MzoplzQ8pU1BZtO5xhi1zCwEX9CUnsozwiRQKoKA7EzZjJjo9vTA0JSzI7lGyaeD 1vdLdhwQR4G+1wnp/msfH6c5a46j7hoZuoxTOCXXqeHYN1LfC/0BLfat9Xyxx13jo545 739q8vmfI7/GUSUgBKEkh/BvSLpIjpecFXyNPlDD4/sNSGUZ7AqN65+3jnjpQHiRRGss cRhQ== X-Gm-Message-State: AIkVDXJPC2XwUXHoYqcYMDE6RRgYHLtLSzMHd50BxmiP9r72Sdmb7/89LEKFVtwEu1UEHw== X-Received: by 10.28.30.79 with SMTP id e76mr9705587wme.96.1485694427705; Sun, 29 Jan 2017 04:53:47 -0800 (PST) Received: from localhost.localdomain ([77.237.117.210]) by smtp.gmail.com with ESMTPSA id h75sm17587941wrh.37.2017.01.29.04.53.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Jan 2017 04:53:46 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Sun, 29 Jan 2017 13:53:22 +0100 Message-Id: <20170129125322.23442-1-onemda@gmail.com> X-Mailer: git-send-email 2.9.3 Subject: [FFmpeg-devel] [PATCH] avutil/eval: add atan2 function 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Paul B Mahol --- doc/utils.texi | 3 +++ libavutil/eval.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/utils.texi b/doc/utils.texi index 30a962a..1734439 100644 --- a/doc/utils.texi +++ b/doc/utils.texi @@ -776,6 +776,9 @@ Compute arcsine of @var{x}. @item atan(x) Compute arctangent of @var{x}. +@item atan2(x, y) +Compute principal value of the arc tangent of @var{y}/@var{x}. + @item between(x, min, max) Return 1 if @var{x} is greater than or equal to @var{min} and lesser than or equal to @var{max}, 0 otherwise. diff --git a/libavutil/eval.c b/libavutil/eval.c index 2d49154..7e86615 100644 --- a/libavutil/eval.c +++ b/libavutil/eval.c @@ -155,7 +155,7 @@ struct AVExpr { e_pow, e_mul, e_div, e_add, e_last, e_st, e_while, e_taylor, e_root, e_floor, e_ceil, e_trunc, e_sqrt, e_not, e_random, e_hypot, e_gcd, - e_if, e_ifnot, e_print, e_bitand, e_bitor, e_between, e_clip + e_if, e_ifnot, e_print, e_bitand, e_bitor, e_between, e_clip, e_atan2 } type; double value; // is sign in other types union { @@ -306,6 +306,7 @@ static double eval_expr(Parser *p, AVExpr *e) case e_last:return e->value * d2; case e_st : return e->value * (p->var[av_clip(d, 0, VARS-1)]= d2); case e_hypot:return e->value * hypot(d, d2); + case e_atan2:return e->value * atan2(d, d2); case e_bitand: return isnan(d) || isnan(d2) ? NAN : e->value * ((long int)d & (long int)d2); case e_bitor: return isnan(d) || isnan(d2) ? NAN : e->value * ((long int)d | (long int)d2); } @@ -452,6 +453,7 @@ static int parse_primary(AVExpr **e, Parser *p) else if (strmatch(next, "bitor" )) d->type = e_bitor; else if (strmatch(next, "between"))d->type = e_between; else if (strmatch(next, "clip" )) d->type = e_clip; + else if (strmatch(next, "atan2" )) d->type = e_atan2; else { for (i=0; p->func1_names && p->func1_names[i]; i++) { if (strmatch(next, p->func1_names[i])) {