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 342A84599C for ; Thu, 28 Dec 2023 15:01:10 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4390168CC40; Thu, 28 Dec 2023 17:01:08 +0200 (EET) Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D3AD768CADB for ; Thu, 28 Dec 2023 17:01:01 +0200 (EET) Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-50e68e93be1so5019340e87.0 for ; Thu, 28 Dec 2023 07:01:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703775660; x=1704380460; darn=ffmpeg.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:to:from:date:from:to:cc:subject :date:message-id:reply-to; bh=9l35lvw4k1ZuiCYJHmtDOv/HYkYJh7cKDTjcgNnCEPg=; b=ifi5YDaGWlmPTQ9raIWAImZ00rOvzGuXaUCh+X0CT4TIWL83oOYiY37eKm88mzcy0H ZCLZaXg2BSbATszi7MZ6tFUIvWeBGwV+RghH7nd8+UTZTaDO8IvLU4LaLAoqbOncsyLB 2upxVKiupTiIlAHpFKxwweyQOkMKB11IB9z4Jd9V6NfT9lw0SE9twmGMk1kX8DLEbDJx cwaJ84mE+Kl0O18v3O5lBZo409v/T1+vNefPwEcK9161ASlyrPdOs17PJR7CgZ1/8IVK Argb6eWh6r+EYxQoto4o3m2XGjF01HLQc5GJUOEGegzb57A629AEoo4c3sL184nNIaGj i8/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703775660; x=1704380460; h=user-agent:in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=9l35lvw4k1ZuiCYJHmtDOv/HYkYJh7cKDTjcgNnCEPg=; b=toD/dBKi5jmNWUTj+jCyU/zlglkPSvhX5r5v5PJf5LLmGV0PA6vvv3ovkNqn3nT9iE hZWmaBxYaLYa8dCO50BCo+kzws1FTufgW9ck+ZVHWZyqgpcYhmi86p0agCZ3r+yK7oPJ 8SIbtgEmK0M70zovYdNSnt1yOAYG5svsLPb5PHgE4BYXVmwekz4h4hbx/+Wb6hIm9+qB FCtdulzexXWPSdeMIkIcjpufSyn550VPKRt+8OJjFQN68ELEp/eti4dQ42N6KpHKmmm7 YYiDtUmKBa8sGpOwV6otbSIM5iXWK7JxDJECvrfSu0tTaqMCef3BteSvVi+lCqr8MBVg 4MzA== X-Gm-Message-State: AOJu0YxGrKPGne4eZo6VE7813aPOIVZSL2dIDAa1FSrFHvBwGCEXTisa Can5Xr76OY1hBGOTefohs6WjpKynkSo= X-Google-Smtp-Source: AGHT+IFNN5Lrf98xIfr4tNKIR/oEqnqiwEZaps5ALM0R7yIqjyA/LLO4LGGXpLKWJ7NUNOWTzZr6+A== X-Received: by 2002:a05:6512:2346:b0:50e:7dd2:4104 with SMTP id p6-20020a056512234600b0050e7dd24104mr2984212lfu.56.1703775659989; Thu, 28 Dec 2023 07:00:59 -0800 (PST) Received: from mariano (dynamic-adsl-84-220-189-10.clienti.tiscali.it. [84.220.189.10]) by smtp.gmail.com with ESMTPSA id qw18-20020a170906fcb200b00a274f3396a0sm1370368ejb.145.2023.12.28.07.00.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 07:00:59 -0800 (PST) Received: by mariano (Postfix, from userid 1000) id C578ABFCDC; Thu, 28 Dec 2023 16:00:57 +0100 (CET) Date: Thu, 28 Dec 2023 16:00:57 +0100 From: Stefano Sabatini To: FFmpeg development discussions and patches Message-ID: Mail-Followup-To: FFmpeg development discussions and patches References: <20231228003839.860894-1-stefasab@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.1.4 (2021-12-11) Subject: Re: [FFmpeg-devel] [PATCH 2/2] lavfi/setpts: introduce rand() function in expression 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: On date Thursday 2023-12-28 12:02:59 +0100, Andreas Rheinhardt wrote: > Stefano Sabatini: > > This is useful to simulate random jitter. > > --- > > Changelog | 1 + > > doc/filters.texi | 10 +++++++++- > > libavfilter/setpts.c | 39 +++++++++++++++++++++++++++++++++------ > > 3 files changed, 43 insertions(+), 7 deletions(-) > > > > diff --git a/Changelog b/Changelog > > index 424bfc11af..ed01c53264 100644 > > --- a/Changelog > > +++ b/Changelog > > @@ -15,6 +15,7 @@ version : > > - tiltandshift filter > > - qrencode filter and qrencodesrc source > > - quirc filter > > +- lavfi/setpts: introduce rand() function in expression > > > > version 6.1: > > - libaribcaption decoder > > diff --git a/doc/filters.texi b/doc/filters.texi > > index d1f95b9781..1d9a5d6c7d 100644 > > --- a/doc/filters.texi > > +++ b/doc/filters.texi > > @@ -30946,7 +30946,7 @@ The expression which is evaluated for each frame to construct its timestamp. > > @end table > > > > The expression is evaluated through the eval API and can contain the following > > -constants: > > +constants and functions: > > > > @table @option > > @item FRAME_RATE, FR > > @@ -31010,6 +31010,8 @@ The timebase of the input timestamps. > > @item T_CHANGE > > Time of the first frame after command was applied or time of the first frame if no commands. > > > > +@item rand(min, max) > > +a random number included between min and max > > @end table > > > > @subsection Examples > > @@ -31021,6 +31023,12 @@ Start counting PTS from zero > > setpts=PTS-STARTPTS > > @end example > > > > +@item > > +Apply a random jitter effect of +/-100 TB units: > > +@example > > +setpts=PTS+100rand(-100\,100) > > +@end example > > + > > @item > > Apply fast motion effect: > > @example > > diff --git a/libavfilter/setpts.c b/libavfilter/setpts.c > > index 88a8d6af86..0f24a900b3 100644 > > --- a/libavfilter/setpts.c > > +++ b/libavfilter/setpts.c > > @@ -32,6 +32,8 @@ > > #include "libavutil/internal.h" > > #include "libavutil/mathematics.h" > > #include "libavutil/opt.h" > > +#include "libavutil/lfg.h" > > +#include "libavutil/random_seed.h" > > #include "libavutil/time.h" > > #include "audio.h" > > #include "avfilter.h" > > @@ -101,18 +103,39 @@ typedef struct SetPTSContext { > > AVExpr *expr; > > double var_values[VAR_VARS_NB]; > > enum AVMediaType type; > > + AVLFG lfg; > > } SetPTSContext; > > > > #define V(name_) \ > > setpts->var_values[VAR_##name_] > > > > +static double drand(void *ctx, double min, double max) > > +{ > > + SetPTSContext *setpts = ((AVFilterContext *)ctx)->priv; > > + > > + return min + (max-min) / UINT_MAX * av_lfg_get(&setpts->lfg); > > +} > > + [...] > > Why is this added here and not in lavu/eval so that it is available with > all expressions? There is no specific reason. Sometimes you need to have a control over the seed, in this case you need to provide the PRNG context. For the general case, probably we can place a global LFG in the eval module and fetch its generated values. _______________________________________________ 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".