X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fdsd.c;h=95aab61ea482b633a271d036a16b25c5c0c6a694;hb=04f49645a519233f3638104e0df5215758652fcb;hp=8a1fc21b0dfe7d6d5334f9107314fda5cbf482f6;hpb=9606e4b6e68de8c5d9ffe0c829716f0d5dbf1215;p=ffmpeg diff --git a/libavcodec/dsd.c b/libavcodec/dsd.c index 8a1fc21b0df..95aab61ea48 100644 --- a/libavcodec/dsd.c +++ b/libavcodec/dsd.c @@ -21,6 +21,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/thread.h" #include "libavcodec/internal.h" #include "libavcodec/mathops.h" #include "avcodec.h" @@ -45,20 +46,17 @@ static av_cold void dsd_ctables_tableinit(void) av_cold void ff_init_dsd_data(void) { - static int done = 0; - if (done) - return; - dsd_ctables_tableinit(); - done = 1; + static AVOnce init_static_once = AV_ONCE_INIT; + ff_thread_once(&init_static_once, dsd_ctables_tableinit); } void ff_dsd2pcm_translate(DSDContext* s, size_t samples, int lsbf, - const unsigned char *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, float *dst, ptrdiff_t dst_stride) { - unsigned char buf[FIFOSIZE]; + uint8_t buf[FIFOSIZE]; unsigned pos, i; - unsigned char* p; + uint8_t* p; double sum; pos = s->pos; @@ -74,8 +72,8 @@ void ff_dsd2pcm_translate(DSDContext* s, size_t samples, int lsbf, sum = 0.0; for (i = 0; i < CTABLES; i++) { - unsigned char a = buf[(pos - i) & FIFOMASK]; - unsigned char b = buf[(pos - (CTABLES*2 - 1) + i) & FIFOMASK]; + uint8_t a = buf[(pos - i) & FIFOMASK]; + uint8_t b = buf[(pos - (CTABLES*2 - 1) + i) & FIFOMASK]; sum += ctables[i][a] + ctables[i][b]; }