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 48CA7479D2 for ; Thu, 28 Sep 2023 19:17:38 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 11AE068CB7E; Thu, 28 Sep 2023 22:17:35 +0300 (EEST) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8572668CA91 for ; Thu, 28 Sep 2023 22:17:28 +0300 (EEST) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 37F28408F8 for ; Thu, 28 Sep 2023 21:17:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1695928648; bh=6k7rnlx7XcSIHvs13+LfopMtRQRl3nN2VdW9iaV4sjk=; h=Date:From:To:Subject:In-Reply-To:References:From; b=ugf/70yLI3eJZBn2PTUPnQaDtLQhusYU5534gNqyYQ727I272NBcdisEtZxv022ee ZAbkui4F1piuKTStHhRdcMePsSZRGnUUTKMCCMZUwMBPYT5saACEqI6Yyre5eixkW8 UNfSkc1LSWmuBKvecv8Xtg8G+4k+BEJL8Y/zAHOs= Date: Thu, 28 Sep 2023 21:17:28 +0200 Message-ID: <20230928211728.GB106730@haasn.xyz> From: Niklas Haas To: FFmpeg development discussions and patches In-Reply-To: <20230928185344.GY3543730@pb2> References: <20230927135617.33952-1-ffmpeg@haasn.xyz> <20230928185344.GY3543730@pb2> MIME-Version: 1.0 Content-Disposition: inline Subject: Re: [FFmpeg-devel] [PATCH 1/3] lavc/h274: fix PRNG definition 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 Thu, 28 Sep 2023 20:53:44 +0200 Michael Niedermayer wrote: > On Wed, Sep 27, 2023 at 03:56:15PM +0200, Niklas Haas wrote: > > From: Niklas Haas > > > > The spec specifies x^31 + x^3 + 1 as the polynomial, but the diagram in > > Figure 1-1 omits the +1 offset. The initial implementation was based on > > the diagram, but this is wrong (produces subtly incorrect results). > > the +1 changes "nothing" > if you take the prng with and without the +1 the 2 will produce 2 > sequences that are negations of each other > > or said different if you start one from 1 and the other from ~1 > they will produce the same sequence just 0 and 1 swaped > > you can also compute 32 bits at once using this: > (this needs 64bits of the sequence as input though) > not sure how useful it is, but it produces more bits quicker > > static void prng_shift32(uint64_t *state) > { > uint64_t x = *state; > uint64_t y = x ^ x>>3; > y ^= y>>6; > y ^= y>>12; > uint32_t feedback = (x >> 1) ^ (y >> 5) ^ (x >> 29) ^ (x >> 30); > *state = (x << 32) | feedback; > } Thanks for the explanation and tip. In this case, PRNG output is by far not the bottleneck (we only need one 32-bit random value per 16x16 block), so I don't think it needs to be modified further. _______________________________________________ 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".