Mercurial > libavcodec.hg
comparison pthread.c @ 10954:d7ef6611a49e libavcodec
Always call avcodec_thread_init()
The various avcodec_thread_init() functions are updated to return
immediately after setting avctx->thread_count. This allows -threads 0
to pass through to codecs. It also simplifies the usage for apps
using libavcodec.
| author | mru |
|---|---|
| date | Wed, 20 Jan 2010 22:55:50 +0000 |
| parents | 98501365c3aa |
| children | 8de15f200be8 |
comparison
equal
deleted
inserted
replaced
| 10953:eb9a2581f50e | 10954:d7ef6611a49e |
|---|---|
| 143 int avcodec_thread_init(AVCodecContext *avctx, int thread_count) | 143 int avcodec_thread_init(AVCodecContext *avctx, int thread_count) |
| 144 { | 144 { |
| 145 int i; | 145 int i; |
| 146 ThreadContext *c; | 146 ThreadContext *c; |
| 147 | 147 |
| 148 avctx->thread_count = thread_count; | |
| 149 | |
| 150 if (thread_count <= 1) | |
| 151 return 0; | |
| 152 | |
| 148 c = av_mallocz(sizeof(ThreadContext)); | 153 c = av_mallocz(sizeof(ThreadContext)); |
| 149 if (!c) | 154 if (!c) |
| 150 return -1; | 155 return -1; |
| 151 | 156 |
| 152 c->workers = av_mallocz(sizeof(pthread_t)*thread_count); | 157 c->workers = av_mallocz(sizeof(pthread_t)*thread_count); |
| 154 av_free(c); | 159 av_free(c); |
| 155 return -1; | 160 return -1; |
| 156 } | 161 } |
| 157 | 162 |
| 158 avctx->thread_opaque = c; | 163 avctx->thread_opaque = c; |
| 159 avctx->thread_count = thread_count; | |
| 160 c->current_job = 0; | 164 c->current_job = 0; |
| 161 c->job_count = 0; | 165 c->job_count = 0; |
| 162 c->job_size = 0; | 166 c->job_size = 0; |
| 163 c->done = 0; | 167 c->done = 0; |
| 164 pthread_cond_init(&c->current_job_cond, NULL); | 168 pthread_cond_init(&c->current_job_cond, NULL); |
