Unified · Split
| @@ -132,14 +132,16 @@ av_cold int ff_slice_thread_init(AVCodecContext *avctx) · 131 unmodified lines | ||
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | avctx->internal->thread_ctx = c = av_mallocz(sizeof(*c)); |
| 135 | + if (!c) | |
| 136 | + return AVERROR(ENOMEM); | |
| 135 | 137 | mainfunc = ffcodec(avctx->codec)->caps_internal & FF_CODEC_CAP_SLICE_THREAD_HAS_MF ? &main_function : NULL; |
| 136 | − if (!c || (thread_count = avpriv_slicethread_create(&c->thread, avctx, worker_func, mainfunc, thread_count)) <= 1) { | |
| 137 | − if (c) | |
| 138 | − avpriv_slicethread_free(&c->thread); | |
| 139 | − av_freep(&avctx->internal->thread_ctx); | |
| 138 | + thread_count = avpriv_slicethread_create(&c->thread, avctx, worker_func, | |
| 139 | + mainfunc, thread_count); | |
| 140 | + if (thread_count <= 1) { | |
| 141 | + ff_slice_thread_free(avctx); | |
| 140 | 142 | avctx->thread_count = 1; |
| 141 | 143 | avctx->active_thread_type = 0; |
| 142 | − return 0; | |
| 144 | + return thread_count < 0 ? thread_count : 0; | |
| 143 | 145 | } |
| 144 | 146 | avctx->thread_count = thread_count; |
| 145 | 147 | |