avcodec: Make av_register_hwaccel() and avcodec_register() thread safe