[FFmpeg-devel] [PATCH v2 143/162] avcodec/aac*: Make initializing ff_aac_pow*sf_tab thread-safe

Michael Niedermayer michael at niedermayer.cc
Fri Nov 20 20:59:17 EET 2020


On Fri, Nov 20, 2020 at 08:33:08AM +0100, Andreas Rheinhardt wrote:
> This table is currently initialized up to three times: Once by the
> encoder and twice by the decoders (once by the fixed and once by the
> floating-point decoder); each of these initializations is guarded by an
> AVOnce, yet the fact that there are three of them implies that there
> might be data races (the fact that each entry is only written to once
> (to its final value) when initializing means that this is safe in
> practice, yet it is still undefined behaviour). Fix this by only
> initializing the table from one place that is guarded by one AVOnce.
> This also avoids unnecessary duplications of the init code.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
>  libavcodec/aacenc.c | 12 +----------
>  libavcodec/aactab.c | 52 +++++++++++++++++++++++++++++++++++++++++++++
>  libavcodec/aactab.h | 46 +--------------------------------------
>  3 files changed, 54 insertions(+), 56 deletions(-)

LGTM

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20201120/bad4d3f8/attachment.sig>


More information about the ffmpeg-devel mailing list