break;
}
- if (s->codec_id == AV_CODEC_ID_IFF_ILBM || s->codec_id == AV_CODEC_ID_IFF_BYTERUN1) {
+ if (s->codec_id == AV_CODEC_ID_IFF_ILBM) {
w_align = FFMAX(w_align, 8);
}
{
int ret = 0;
- ff_unlock_avcodec();
+ ff_unlock_avcodec(codec);
ret = avcodec_open2(avctx, codec, options);
av_log(avctx, AV_LOG_WARNING, "Warning: not compiled with thread support, using thread emulation\n");
if (CONFIG_FRAME_THREAD_ENCODER) {
- ff_unlock_avcodec(); //we will instanciate a few encoders thus kick the counter to prevent false detection of a problem
+ ff_unlock_avcodec(codec); //we will instanciate a few encoders thus kick the counter to prevent false detection of a problem
ret = ff_frame_thread_encoder_init(avctx, options ? *options : NULL);
ff_lock_avcodec(avctx, codec);
if (ret < 0)
}
end:
- ff_unlock_avcodec();
+ ff_unlock_avcodec(codec);
if (options) {
av_dict_free(options);
*options = tmp;
switch (id) {
case AV_CODEC_ID_ADPCM_AFC:
return frame_bytes / (9 * ch) * 16;
+ case AV_CODEC_ID_ADPCM_PSX:
case AV_CODEC_ID_ADPCM_DTK:
return frame_bytes / (16 * ch) * 28;
case AV_CODEC_ID_ADPCM_4XM:
int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec)
{
+ if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init)
+ return 0;
+
if (lockmgr_cb) {
if ((*lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN))
return -1;
}
- if (avpriv_atomic_int_add_and_fetch(&entangled_thread_counter, 1) != 1 &&
- !(codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE)) {
+ if (avpriv_atomic_int_add_and_fetch(&entangled_thread_counter, 1) != 1) {
av_log(log_ctx, AV_LOG_ERROR,
"Insufficient thread locking. At least %d threads are "
"calling avcodec_open2() at the same time right now.\n",
if (!lockmgr_cb)
av_log(log_ctx, AV_LOG_ERROR, "No lock manager is set, please see av_lockmgr_register()\n");
ff_avcodec_locked = 1;
- ff_unlock_avcodec();
+ ff_unlock_avcodec(codec);
return AVERROR(EINVAL);
}
av_assert0(!ff_avcodec_locked);
return 0;
}
-int ff_unlock_avcodec(void)
+int ff_unlock_avcodec(const AVCodec *codec)
{
+ if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init)
+ return 0;
+
av_assert0(ff_avcodec_locked);
ff_avcodec_locked = 0;
avpriv_atomic_int_add_and_fetch(&entangled_thread_counter, -1);