aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorAlexander Strange <astrange@ithinksw.com>2011-02-17 03:25:00 -0500
committerRonald S. Bultje <rsbultje@gmail.com>2011-03-01 11:39:12 -0500
commitad9791e12b6653a465803062e2543f25916300d3 (patch)
tree4ac08d53edc03be941c7baade9f927a5c73cfb22 /libavcodec
parent00ba041cb396f88f68a1bf7907e7c98ded3760ab (diff)
downloadffmpeg-ad9791e12b6653a465803062e2543f25916300d3.tar.gz
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: Ronald S. Bultje <rsbultje@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/pthread.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
index 0e033d37c0..5b0d108ba5 100644
--- a/libavcodec/pthread.c
+++ b/libavcodec/pthread.c
@@ -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);