On Wed, 26 Mar 2014 04:41:27 -0700
Diego Biurrun <[email protected]> wrote:
> ---
> libavcodec/dsputil.c | 10 ++++++++--
> libavcodec/dsputil.h | 1 -
> libavcodec/utils.c | 13 -------------
> 3 files changed, 8 insertions(+), 16 deletions(-)
>
> diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
> index 534bc92..b29e959 100644
> --- a/libavcodec/dsputil.c
> +++ b/libavcodec/dsputil.c
> @@ -2440,11 +2440,15 @@ static void clear_blocks_8_c(int16_t *blocks)
> memset(blocks, 0, sizeof(int16_t) * 6 * 64);
> }
>
> -/* init static data */
> -av_cold void ff_dsputil_static_init(void)
> +static av_cold void square_tab_init(void)
> {
> + static int initialized = 0;
> int i;
>
> + if (initialized != 0)
> + return;
> + initialized = 1;
> +
> for (i = 0; i < 512; i++)
> ff_square_tab[i] = (i - 256) * (i - 256);
> }
> @@ -2453,6 +2457,8 @@ av_cold void ff_dsputil_init(DSPContext *c,
> AVCodecContext *avctx)
> {
> const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8;
>
> + square_tab_init();
> +
> #if CONFIG_ENCODERS
> if (avctx->bits_per_raw_sample == 10) {
> c->fdct = ff_jpeg_fdct_islow_10;
> diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h
> index 7f467d1..2bc1aec 100644
> --- a/libavcodec/dsputil.h
> +++ b/libavcodec/dsputil.h
> @@ -314,7 +314,6 @@ typedef struct DSPContext {
> op_fill_func fill_block_tab[2];
> } DSPContext;
>
> -void ff_dsputil_static_init(void);
> void ff_dsputil_init(DSPContext *p, AVCodecContext *avctx);
>
> void ff_set_cmp(DSPContext *c, me_cmp_func *cmp, int type);
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index c88b346..738e247 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -91,18 +91,6 @@ AVCodec *av_codec_next(const AVCodec *c)
> return first_avcodec;
> }
>
> -static av_cold void avcodec_init(void)
> -{
> - static int initialized = 0;
> -
> - if (initialized != 0)
> - return;
> - initialized = 1;
> -
> - if (CONFIG_DSPUTIL)
> - ff_dsputil_static_init();
> -}
> -
> int av_codec_is_encoder(const AVCodec *codec)
> {
> return codec && (codec->encode_sub || codec->encode2);
> @@ -116,7 +104,6 @@ int av_codec_is_decoder(const AVCodec *codec)
> av_cold void avcodec_register(AVCodec *codec)
> {
> AVCodec **p;
> - avcodec_init();
> p = &first_avcodec;
> while (*p != NULL)
> p = &(*p)->next;
It looks like dsputil stuff is now initialized from every decoder,
instead of avcodec_register(). Doesn't this cause additional issues
with thread-safety?
Or does it not matter that 2 threads might call ff_dsputil_static_init
at the same time?
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel