]> git.sesse.net Git - ffmpeg/commit
avcodec/aac*: Make initializing ff_aac_pow*sf_tab thread-safe
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Thu, 19 Nov 2020 15:54:45 +0000 (16:54 +0100)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Tue, 24 Nov 2020 10:35:03 +0000 (11:35 +0100)
commit195d8ce85eb73ff283f85dcee63383ec4081e3e7
tree9e71532be20394daa1fdc4b1e637251ada721d40
parentc4b4cd775af0f4b83c34fd595c05d2fa99018323
avcodec/aac*: Make initializing ff_aac_pow*sf_tab thread-safe

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 a single AVOnce.
This also avoids unnecessary duplications of the init code.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/aacenc.c
libavcodec/aactab.c
libavcodec/aactab.h