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 ESMTPS id EA2694C3B1 for ; Thu, 6 Feb 2025 22:05:05 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A86F268BA9F; Fri, 7 Feb 2025 00:05:02 +0200 (EET) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 664F068B642 for ; Fri, 7 Feb 2025 00:04:56 +0200 (EET) Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-5440d5b30a8so1680171e87.2 for ; Thu, 06 Feb 2025 14:04:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20230601.gappssmtp.com; s=20230601; t=1738879495; x=1739484295; darn=ffmpeg.org; h=mime-version:references:message-id:in-reply-to:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=p9DR+4hvaz/18Reth9zvEexqx4C4YsopEaq430Qbku0=; b=njhM+wqmQrGeX/+HhvigtH0jK4FcwtUGyXXpLZle3AN0zwd+d7mWDusUT4gHi8/lxY 1sNwgwzrnWHaRZZtW1qwaJ/iJQTSV1zDW5ZF3kn47LYNF1G1wwG3IChMAFUnrS00cd/o rrzzh2bNn1vPn3M+vPIFpaB/hTOdLQq4vhdKfidsxj8qvMep3bIeFl16pmIibRI0CLPV tJkkYq1w73EBpu2SNBIBzi7JBXz14aWS1cwQPfvtGLJB7T/UyDS3/5joldQBGtw9OKeR PfDuNNElLYIk3ki4HU1eg1fLTA8xRQt+J7sVDuLJaTAMObogoRnMCFh2ZwNDwMb/OJsT Lqsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738879495; x=1739484295; h=mime-version:references:message-id:in-reply-to:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=p9DR+4hvaz/18Reth9zvEexqx4C4YsopEaq430Qbku0=; b=PzXLJ6Ljh/sio1f2/2cIgJ+bUTH3aUpgHwrL93bbNkyc0dtVrihhLGMI5u5uD6Mw82 GXu6d9U7xdPD6ldyVdxWx78N1VOnvkMXJeaYMlpNJd/llwPijhdhvHVUolLGoBvjPTlf Y5sGL3wFBWn1iXl4EDARnX1wf7aEhEqvAEfb+DSDGLbtac7h7torpSlEfbwIC4Iqqi3n B88e23rh3jsdpUYmF8zKjoad+2v1vHdTq7Rqh/mKEvNcKqgT7FLqx00fgOzQSwJ2DrYG rL6FTzlDpaj0shJtZM05vCxIh+VaO1ISzFojuIzZpnigrClR7HSllaq7K0ypgrnGcNtu po7A== X-Gm-Message-State: AOJu0Yxg/gajAwzNN0Q9Bwj1V3nUF4Vnn7d+xXtEysq94G9xf8bxb6AV IL36YRZqJeC/zdK/8dMET6Nudc9HipVkmcnHFMirpSzsKFtC2N/+EJHr6eOl8ZiPY2qGxT7QP7Y 3+A== X-Gm-Gg: ASbGnctdleoULw7zQi4uNZ5z8MXH36Rx1aIACAJ5LCDVTVSC6kS3SDDBsVc1c7ZOeuB 0yUQIF6CZUT/pbuMuhMmoDet/JDjErIiEtuawqbV0rz24XE5QfpmPCGZzfXYidCSkO7dDk0BnCs Vj/anUIWXUoS/N2HgcjtolNkDYuGvvBX92RO7EWviCA9O9ejWnZ364FCIo6Ad8Uk6AOukn90aV0 AcB1UAWsz2sY45MZH0r5cWv7AFWebh1hp8ig0Aq++NoWR0SAwVZcrT0rtNdvMN8HCQ/Zz66nm90 maOXhhv8tKYNtm9UveLvk4bFX5mXiUmXC7Cpu1PNoiQgUSmqJkyvW/ob0wVAjt6hOhqXGz/qRxO W4jgHdwKPcxc= X-Google-Smtp-Source: AGHT+IEavI9p8rJ7scLtbsaiLOqjq5MegGSNsB1miC97Ltk2ZmPN8xX3mSkUIrI/pFAW4EnI13XFhA== X-Received: by 2002:a05:6512:1385:b0:541:1c49:26a with SMTP id 2adb3069b0e04-54414b05788mr169446e87.43.1738879495072; Thu, 06 Feb 2025 14:04:55 -0800 (PST) Received: from tunnel335574-pt.tunnel.tserv24.sto1.ipv6.he.net (tunnel335574-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:11::2]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5441055573asm249666e87.81.2025.02.06.14.04.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 14:04:54 -0800 (PST) Date: Fri, 7 Feb 2025 00:04:53 +0200 (EET) From: =?ISO-8859-15?Q?Martin_Storsj=F6?= To: FFmpeg development discussions and patches In-Reply-To: <20250206160443.GT4991@pb2> Message-ID: <317e9c7e-bc5-81dc-f036-9b1426a95b1@martin.st> References: <20250205221813.4110398-1-martin@martin.st> <20250205221813.4110398-2-martin@martin.st> <20250206001638.GI4991@pb2> <20250206160443.GT4991@pb2> MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [FFmpeg-devel] [PATCH v2 2/2] random_seed: Improve behaviour with small timer increments with high precision timers 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Thu, 6 Feb 2025, Michael Niedermayer wrote: > On Thu, Feb 06, 2025 at 02:38:48PM +0200, Martin Storsj=F6 wrote: >> On Thu, 6 Feb 2025, Michael Niedermayer wrote: >> >>>> + // If the timer resolution is high, and we get the same t= imer >>>> + // value multiple times, use variances in the number of r= epeats >>>> + // of each timer value as entropy. If the number of repea= ts changed, >>>> + // proceed to the next index. >>> >>> Does it still work if you check against the last 2 ? >>> or does this become too slow ? >>> What iam thinking of is this >>> >>> 7,8,7,8,8,7,8,7,8,8,7,8,7,8,8,7,8,7,8,8,... and a 9 or 6 or further dis= tant would trigger it >>> >>> I assume both the CPU clock and the wall time are quite precisse so if = we >>> just compare them the entropy could be low even with 2 alternating valu= es >> >> Yes, that still works for making it terminate in a reasonable amount of >> time. I updated the patch to keep track of 3 numbers of repeats, and we >> consider that we got valid entropy once the new number of repeats is >> different from the last two. >> >> So in the sequence above, e.g. for 7,8,7,8,8,7, at the point of the last >> one, we have old repeats 8 and 8, and the new repeat count 7, which in t= hat >> context looks unique. > > I was thinking that in 7,8,8 that 7 and 8 be the 2 least recent used > values not 8,8 Sure, that's probably doable too. > that is, something like: > > if (old2 =3D=3D new) { > FFSWAP(old,old2); I don't see why we'd need to check this if clause at all, it seems to me = that it's enough to have the "if (old !=3D new)" case. If we have old2 =3D= =3D = new, we'd just end up with old2 =3D old, and old =3D (previous old2 value) = anyway. > } else if (old !=3D new) { > old2 =3D old; > old =3D new; > } > > but again, iam not sure this will work or just need too much time to gath= er > enough entropy It still executes in reasonable amount of time; my patch now looks like = this: if (t =3D=3D last_t) { repeats[0]++; } else { // If we got a new unique number of repeats, update the histor= y. // (We don't need to check repeats[2]; if it is equal to the n= ew // value we'll end up keeping the same two values as before, in // opposite order. if (repeats[0] !=3D repeats[1]) { repeats[2] =3D repeats[1]; repeats[1] =3D repeats[0]; } repeats[0] =3D 0; } // Martin _______________________________________________ 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".