From patchwork Wed Apr 10 13:47:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Sabatini X-Patchwork-Id: 48006 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c90a:b0:1a7:a0dc:8de5 with SMTP id gx10csp565694pzb; Wed, 10 Apr 2024 06:48:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVWnY8vWCdqTKE+9Kn2Q8Ymi8S08oI+L0p80xgsi5fc4nPrKEs9revIpyeE3TQtpzfNAGvPN2N0YAJAaIfJoBXtgzl/GoF4kwNJ2Q== X-Google-Smtp-Source: AGHT+IGpzOtGB1x8vv852uUL3MZO4BSzZC0ulsyrXUNsno2YqiyxZkFtm9gi8qVmth9kUki2v6Yo X-Received: by 2002:a50:a418:0:b0:56e:2458:eea3 with SMTP id u24-20020a50a418000000b0056e2458eea3mr1805685edb.10.1712756892605; Wed, 10 Apr 2024 06:48:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712756892; cv=none; d=google.com; s=arc-20160816; b=P3R0buOQID26eeaFjH38/goqlF+S1Rjw2p8ELcFauuFkI97Arx5YY05wktqCWNhcEd yYABU7qzZrgiFWqTZfwloo2bp+EexkVATAQx68SbMTy2L9506gck56KKp2YbsBUfU/iE CTrhZ89z3jR0duS7LNcNYDe1aaQPqIUKeDqj/IEEbGDdDtCmOqXj4nkQeDaOdvIrVE9C dnF7w9BfTmTHarzuN9x+IyCoDPBmvPzQFR0/nGcDcNxzjNDdkOiii8+Q5qlSZFMMi3ZR s9Dfk2Vsfcpaiv8ofFaKNYQvvnx5RzSfDKb8g3CvO5lo6T3m49buAgTM17Wx00LzSEmf 5ZxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=zilJD/n7yTjpSIozq3IMFXj8jPuMZwVVHssoXC7dkqc=; fh=QdWxt2OToL83TTnLQn0lGhLakV7i1QyAJdC8te7qN0E=; b=c3RPhK+udje7m6sV0seZ6gX3AbdWW9NbJQdEAaGOzAIy7UOtYMBxpg+PvYMiKD+9Dt xOYlt02EoFIIL9UFo7seKoeeB413ueLmJDxS0Ld14DPwlOjqlmo6IwyTokKFDnkedwMN U/1hcAPNP3q3Fdxbgk3E3bhAZq51D4+Kjmlugy4xpTKMbj/ZdbCZsK52ILJ9GAtynajC mvWhj5VhvrkuFuqbiMrfG1BCNDx5Qf04VapyK2iUsWOGu/rLRBF3EIxCgL4tHntK2Jdx wnbY32+0gh8SXWvjBXLBuvaGIzp+jMjPwsY3s92WWaszRTG5wK0dzyh1w4uicAUsQ/Bp kvng==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=iGw2Q3TK; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z17-20020a5096d1000000b0056c303d81adsi5962459eda.435.2024.04.10.06.48.12; Wed, 10 Apr 2024 06:48:12 -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=@gmail.com header.s=20230601 header.b=iGw2Q3TK; 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=QUARANTINE 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 4757D68CF68; Wed, 10 Apr 2024 16:47:58 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 57AF668C934 for ; Wed, 10 Apr 2024 16:47:50 +0300 (EEST) Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a51d3193e54so396019566b.2 for ; Wed, 10 Apr 2024 06:47:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712756869; x=1713361669; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=539GRzsBomG6qmv1xA662epzTZ+o3AP117IrFD85X6s=; b=iGw2Q3TKbBI6zccNa9S2+hqS2bLg+NlxhnrzfuoIXX7KBEkJquP4cGkOcnTVP3WdwL MMir6AcTsXjzBghOGkl5RCH9zfobZJAiPkUpxaJ2nY8Km0Pe9mnrbS3qpKeuYQGnbZ3+ rVbZ7AecC4OkjaozfWOV/JP6/GcqG/n0Ed8PLE9Blcy9rQmgpVnL0MMp73VwgY6xSoSW EuHg+XySnjraAo/frnf0weeya3sFi94e9rFwnCwCYMoTxgN3fl6fekrsUavXfyKFm8Jx UiOkAcKsXRQie3nFxBwhwvToFNGvCfZmKnJDAQGHAS5xcYf718Wpsk9PTcx/8pjbSuib R5+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712756869; x=1713361669; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=539GRzsBomG6qmv1xA662epzTZ+o3AP117IrFD85X6s=; b=OXzxkT7R9/b8TlQD1/zushWI6xXbgYFfkEKXQSeqrU1qkV1qzYwp3Tioc1+by2kBz0 2a258Aed0t1g2K3Zt6/AXvBcFU92V3ES7o5TNQ4i65uKh/iGx2WElEQ2oAl/0wwWeEWT NPTJ0TFe9xAivot0JwTb0tnzy+/HczP0HbnpnKXNj1YCYDYkXX9ihc8ehNutkforxBU+ dBXsYcihr4X9/IeXCVpuKwwDWiST3ke9gfakrne9rTvDfV2/CetHJ0H3Qk7wiZLKO2/d qMXs6W6vFHlvM0y/vPwt2YiElXnIPbsmULn0ai+LFYWvodT2kRd/OPBNCcipsk71hQj8 mXNg== X-Gm-Message-State: AOJu0Ywymfbecf4Otzf3CBPh4Fey3Ho7W+a4RdepLNH83JOaGLZj09Si qPrEcPY9NypvIzpliWrlVsHG3CQ/Iryltcqv7guDgxPoS5yQPeSVai6SYeny X-Received: by 2002:a17:906:55c5:b0:a51:da29:288c with SMTP id z5-20020a17090655c500b00a51da29288cmr1423226ejp.28.1712756868935; Wed, 10 Apr 2024 06:47:48 -0700 (PDT) Received: from mariano (host-82-58-28-189.retail.telecomitalia.it. [82.58.28.189]) by smtp.gmail.com with ESMTPSA id sa6-20020a1709076d0600b00a46ab3adea5sm6921357ejc.113.2024.04.10.06.47.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 06:47:48 -0700 (PDT) Received: by mariano (Postfix, from userid 1000) id 92F58BFCE8; Wed, 10 Apr 2024 15:47:47 +0200 (CEST) From: Stefano Sabatini To: FFmpeg development discussions and patches Date: Wed, 10 Apr 2024 15:47:47 +0200 Message-Id: <20240410134747.58471-1-stefasab@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] doc/utils/eval: review and extend, clarify ld/st index meaning 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 Cc: Stefano Sabatini Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 6YXcH78YygQJ Prefer idx in place of id for functions accessing the internal variables, and add a short introduction to mention them. --- doc/utils.texi | 60 +++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/doc/utils.texi b/doc/utils.texi index edf3ae24b0..8e4da9eac4 100644 --- a/doc/utils.texi +++ b/doc/utils.texi @@ -801,6 +801,11 @@ The following binary operators are available: @code{+}, @code{-}, The following unary operators are available: @code{+}, @code{-}. +Some internal variables can be used to store and load intermediary +results. They can be accessed using the @code{ld} and @code{st} +functions with an index argument (variying from 0 to 9) to specify +which internal variable to access. + The following functions are available: @table @option @item abs(x) @@ -898,9 +903,9 @@ Return 1.0 if @var{x} is +/-INFINITY, 0.0 otherwise. @item isnan(x) Return 1.0 if @var{x} is NAN, 0.0 otherwise. -@item ld(var) -Load the value of the internal variable with number -@var{var}, which was previously stored with st(@var{var}, @var{expr}). +@item ld(idx) +Load the value of the internal variable with index @var{idx}, which was +previously stored with st(@var{idx}, @var{expr}). The function returns the loaded value. @item lerp(x, y, z) @@ -933,16 +938,14 @@ Compute the power of @var{x} elevated @var{y}, it is equivalent to @item print(t) @item print(t, l) -Print the value of expression @var{t} with loglevel @var{l}. If -@var{l} is not specified then a default log level is used. -Returns the value of the expression printed. - -Prints t with loglevel l +Print the value of expression @var{t} with loglevel @var{l}. If @var{l} is not +specified then a default log level is used. +Return the value of the expression printed. @item random(idx) Return a pseudo random value between 0.0 and 1.0. @var{idx} is the -index of the internal variable which will be used to save the -seed/state. +index of the internal variable used to save the seed/state, which can be +previously stored with @code{st(idx)}. To initialize the seed, you need to store the seed value as a 64-bit unsigned integer in the internal variable with index @var{idx}. @@ -955,8 +958,8 @@ st(0,42); print(random(0)); print(random(0)); print(random(0)) @item randomi(idx, min, max) Return a pseudo random value in the interval between @var{min} and -@var{max}. @var{idx} is the index of the internal variable which will -be used to save the seed/state. +@var{max}. @var{idx} is the index of the internal variable which will be used to +save the seed/state, which can be previously stored with @code{st(idx)}. To initialize the seed, you need to store the seed value as a 64-bit unsigned integer in the internal variable with index @var{idx}. @@ -968,14 +971,14 @@ with argument @var{ld(0)} is 0 in the interval 0..@var{max}. The expression in @var{expr} must denote a continuous function or the result is undefined. -@var{ld(0)} is used to represent the function input value, which means -that the given expression will be evaluated multiple times with -various input values that the expression can access through -@code{ld(0)}. When the expression evaluates to 0 then the -corresponding input value will be returned. +@var{ld(0)} is used to represent the function input value, which means that the +given expression will be evaluated multiple times with various input values that +the expression can access through @code{ld(0)}. When the expression evaluates to +0 then the corresponding input value will be returned. @item round(expr) -Round the value of expression @var{expr} to the nearest integer. For example, "round(1.5)" is "2.0". +Round the value of expression @var{expr} to the nearest integer. For example, +"round(1.5)" is "2.0". @item sgn(x) Compute sign of @var{x}. @@ -993,12 +996,15 @@ Compute the square root of @var{expr}. This is equivalent to @item squish(x) Compute expression @code{1/(1 + exp(4*x))}. -@item st(var, expr) +@item st(idx, expr) Store the value of the expression @var{expr} in an internal -variable. @var{var} specifies the number of the variable where to -store the value, and it is a value ranging from 0 to 9. The function -returns the value stored in the internal variable. -Note, Variables are currently not shared between expressions. +variable. @var{idx} specifies the index of the variable where to store +the value, and it is a value ranging from 0 to 9. The function returns +the value stored in the internal variable. + +The stored value can be retrieved with @code{ld(var)}. + +Note: variables are currently not shared between expressions. @item tan(x) Compute tangent of @var{x}. @@ -1007,16 +1013,16 @@ Compute tangent of @var{x}. Compute hyperbolic tangent of @var{x}. @item taylor(expr, x) -@item taylor(expr, x, id) +@item taylor(expr, x, idx) Evaluate a Taylor series at @var{x}, given an expression representing -the @code{ld(id)}-th derivative of a function at 0. +the @code{ld(idx)}-th derivative of a function at 0. When the series does not converge the result is undefined. -@var{ld(id)} is used to represent the derivative order in @var{expr}, +@var{ld(idx)} is used to represent the derivative order in @var{expr}, which means that the given expression will be evaluated multiple times with various input values that the expression can access through -@code{ld(id)}. If @var{id} is not specified then 0 is assumed. +@code{ld(idx)}. If @var{idx} is not specified then 0 is assumed. Note, when you have the derivatives at y instead of 0, @code{taylor(expr, x-y)} can be used.