thread_count passed to ff_thread_init() is only used to set AVCodecContext.
thread_count, and can be removed. Instead move it to the legacy implementation
of avcodec_thread_init().
This also fixes the problem that calling avcodec_thread_init() with pthreads
enabled did not set it since
ff1efc524cb3c60f2f746e3b4550bb1a86c65316.
Signed-off-by: Janne Grunau <janne-libav@jannau.net>
}
}
-int ff_thread_init(AVCodecContext *avctx, int thread_count)
+int ff_thread_init(AVCodecContext *avctx)
{
if (avctx->thread_opaque) {
av_log(avctx, AV_LOG_ERROR, "avcodec_thread_init is ignored after avcodec_open\n");
*/
void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f);
-int ff_thread_init(AVCodecContext *s, int thread_count);
+int ff_thread_init(AVCodecContext *s);
void ff_thread_free(AVCodecContext *s);
#endif /* AVCODEC_THREAD_H */
avctx->frame_number = 0;
if (HAVE_THREADS && !avctx->thread_opaque) {
- ret = ff_thread_init(avctx, avctx->thread_count);
+ ret = ff_thread_init(avctx);
if (ret < 0) {
goto free_and_end;
}
#endif
#if !HAVE_THREADS
-int ff_thread_init(AVCodecContext *s, int thread_count){
- s->thread_count = thread_count;
+int ff_thread_init(AVCodecContext *s){
return -1;
}
#endif
int avcodec_thread_init(AVCodecContext *s, int thread_count)
{
- return ff_thread_init(s, thread_count);
+ s->thread_count = thread_count;
+ return ff_thread_init(s);
}
void avcodec_thread_free(AVCodecContext *s)
avcodec_thread_execute(s, NULL, arg, ret, count, 0);
}
-int ff_thread_init(AVCodecContext *s, int thread_count){
+int ff_thread_init(AVCodecContext *s){
int i;
ThreadContext *c;
uint32_t threadid;
return 0;
}
- s->thread_count= thread_count;
s->active_thread_type= FF_THREAD_SLICE;
- if (thread_count <= 1)
+ if (s->thread_count <= 1)
return 0;
assert(!s->thread_opaque);
- c= av_mallocz(sizeof(ThreadContext)*thread_count);
+ c= av_mallocz(sizeof(ThreadContext)*s->thread_count);
s->thread_opaque= c;
if(!(c[0].work_sem = CreateSemaphore(NULL, 0, INT_MAX, NULL)))
goto fail;
if(!(c[0].done_sem = CreateSemaphore(NULL, 0, INT_MAX, NULL)))
goto fail;
- for(i=0; i<thread_count; i++){
+ for(i=0; i<s->thread_count; i++){
//printf("init semaphors %d\n", i); fflush(stdout);
c[i].avctx= s;
c[i].work_sem = c[0].work_sem;