1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

avcodec/pthread_slice: Return error on error

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2025-03-15 05:24:51 +01:00
parent c82101c9ce
commit 7d1bf0ac7a

View File

@ -132,14 +132,16 @@ av_cold int ff_slice_thread_init(AVCodecContext *avctx)
}
avctx->internal->thread_ctx = c = av_mallocz(sizeof(*c));
if (!c)
return AVERROR(ENOMEM);
mainfunc = ffcodec(avctx->codec)->caps_internal & FF_CODEC_CAP_SLICE_THREAD_HAS_MF ? &main_function : NULL;
if (!c || (thread_count = avpriv_slicethread_create(&c->thread, avctx, worker_func, mainfunc, thread_count)) <= 1) {
if (c)
avpriv_slicethread_free(&c->thread);
av_freep(&avctx->internal->thread_ctx);
thread_count = avpriv_slicethread_create(&c->thread, avctx, worker_func,
mainfunc, thread_count);
if (thread_count <= 1) {
ff_slice_thread_free(avctx);
avctx->thread_count = 1;
avctx->active_thread_type = 0;
return 0;
return thread_count < 0 ? thread_count : 0;
}
avctx->thread_count = thread_count;