pthread: fixed thread initialization issues related to thread-safe buffer allocator
Signed-off-by: Anatoliy Wasserman <anatoliy.wasserman@yandex.ru> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
committed by
Michael Niedermayer
parent
ec8a3e25d8
commit
6778f9d9f2
@@ -241,8 +241,6 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ff_thread_finish_setup(avctx);
|
|
||||||
|
|
||||||
ctx->dec_params.cp_limit_decoding = NO_LIMITATION;
|
ctx->dec_params.cp_limit_decoding = NO_LIMITATION;
|
||||||
ctx->dec_params.cp_reduce = avctx->lowres;
|
ctx->dec_params.cp_reduce = avctx->lowres;
|
||||||
// Tie decoder with decoding parameters
|
// Tie decoder with decoding parameters
|
||||||
|
|||||||
@@ -301,7 +301,7 @@ static attribute_align_arg void *frame_worker_thread(void *arg)
|
|||||||
|
|
||||||
if (fctx->die) break;
|
if (fctx->die) break;
|
||||||
|
|
||||||
if (!codec->update_thread_context && avctx->thread_safe_callbacks)
|
if (!codec->update_thread_context && (avctx->thread_safe_callbacks || avctx->get_buffer == avcodec_default_get_buffer))
|
||||||
ff_thread_finish_setup(avctx);
|
ff_thread_finish_setup(avctx);
|
||||||
|
|
||||||
pthread_mutex_lock(&p->mutex);
|
pthread_mutex_lock(&p->mutex);
|
||||||
@@ -403,6 +403,7 @@ static void update_context_from_user(AVCodecContext *dst, AVCodecContext *src)
|
|||||||
|
|
||||||
dst->frame_number = src->frame_number;
|
dst->frame_number = src->frame_number;
|
||||||
dst->reordered_opaque = src->reordered_opaque;
|
dst->reordered_opaque = src->reordered_opaque;
|
||||||
|
dst->thread_safe_callbacks = src->thread_safe_callbacks;
|
||||||
#undef copy_fields
|
#undef copy_fields
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -828,7 +829,8 @@ int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (p->state != STATE_SETTING_UP &&
|
if (p->state != STATE_SETTING_UP &&
|
||||||
(avctx->codec->update_thread_context || !avctx->thread_safe_callbacks)) {
|
(avctx->codec->update_thread_context || (!avctx->thread_safe_callbacks &&
|
||||||
|
avctx->get_buffer != avcodec_default_get_buffer))) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() cannot be called after ff_thread_finish_setup()\n");
|
av_log(avctx, AV_LOG_ERROR, "get_buffer() cannot be called after ff_thread_finish_setup()\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user