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