提交 ad9791e1 编写于 作者: A Alexander Strange 提交者: Ronald S. Bultje

pthreads: Fix bug introduced with thread_safe_callbacks

For intra codecs, ff_thread_finish_setup() is called before decoding starts
automatically. However, get_buffer can only be used before it's called, so
adding this requirement broke frame threading for them. Fixed by moving the
call until after get_buffer is finished.
Signed-off-by: NRonald S. Bultje <rsbultje@gmail.com>
上级 00ba041c
......@@ -292,7 +292,8 @@ static attribute_align_arg void *frame_worker_thread(void *arg)
if (fctx->die) break;
if (!codec->update_thread_context) ff_thread_finish_setup(avctx);
if (!codec->update_thread_context && avctx->thread_safe_callbacks)
ff_thread_finish_setup(avctx);
pthread_mutex_lock(&p->mutex);
avcodec_get_frame_defaults(&p->frame);
......@@ -779,7 +780,8 @@ int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)
return avctx->get_buffer(avctx, f);
}
if (p->state != STATE_SETTING_UP) {
if (p->state != STATE_SETTING_UP &&
(avctx->codec->update_thread_context || !avctx->thread_safe_callbacks)) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() cannot be called after ff_thread_finish_setup()\n");
return -1;
}
......@@ -810,6 +812,9 @@ int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)
err = p->result;
pthread_mutex_unlock(&p->progress_mutex);
if (!avctx->codec->update_thread_context)
ff_thread_finish_setup(avctx);
}
pthread_mutex_unlock(&p->parent->buffer_mutex);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册