Signed-off-by: Anatoliy Wasserman <anatoliy.wasserman@yandex.ru>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -241,8 +241,6 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx, |
241 | 241 |
return -1; |
242 | 242 |
} |
243 | 243 |
|
244 |
- ff_thread_finish_setup(avctx); |
|
245 |
- |
|
246 | 244 |
ctx->dec_params.cp_limit_decoding = NO_LIMITATION; |
247 | 245 |
ctx->dec_params.cp_reduce = avctx->lowres; |
248 | 246 |
// Tie decoder with decoding parameters |
... | ... |
@@ -301,7 +301,7 @@ static attribute_align_arg void *frame_worker_thread(void *arg) |
301 | 301 |
|
302 | 302 |
if (fctx->die) break; |
303 | 303 |
|
304 |
- if (!codec->update_thread_context && avctx->thread_safe_callbacks) |
|
304 |
+ if (!codec->update_thread_context && (avctx->thread_safe_callbacks || avctx->get_buffer == avcodec_default_get_buffer)) |
|
305 | 305 |
ff_thread_finish_setup(avctx); |
306 | 306 |
|
307 | 307 |
pthread_mutex_lock(&p->mutex); |
... | ... |
@@ -403,6 +403,7 @@ static void update_context_from_user(AVCodecContext *dst, AVCodecContext *src) |
403 | 403 |
|
404 | 404 |
dst->frame_number = src->frame_number; |
405 | 405 |
dst->reordered_opaque = src->reordered_opaque; |
406 |
+ dst->thread_safe_callbacks = src->thread_safe_callbacks; |
|
406 | 407 |
#undef copy_fields |
407 | 408 |
} |
408 | 409 |
|
... | ... |
@@ -828,7 +829,8 @@ int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f) |
828 | 828 |
} |
829 | 829 |
|
830 | 830 |
if (p->state != STATE_SETTING_UP && |
831 |
- (avctx->codec->update_thread_context || !avctx->thread_safe_callbacks)) { |
|
831 |
+ (avctx->codec->update_thread_context || (!avctx->thread_safe_callbacks && |
|
832 |
+ avctx->get_buffer != avcodec_default_get_buffer))) { |
|
832 | 833 |
av_log(avctx, AV_LOG_ERROR, "get_buffer() cannot be called after ff_thread_finish_setup()\n"); |
833 | 834 |
return -1; |
834 | 835 |
} |