Revision ba9ef8d0

View differences:

libavcodec/pthread.c
882 882
    }
883 883
}
884 884

  
885
int ff_thread_init(AVCodecContext *avctx, int thread_count)
885
int ff_thread_init(AVCodecContext *avctx)
886 886
{
887 887
    if (avctx->thread_opaque) {
888 888
        av_log(avctx, AV_LOG_ERROR, "avcodec_thread_init is ignored after avcodec_open\n");
libavcodec/thread.h
108 108
 */
109 109
void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f);
110 110

  
111
int ff_thread_init(AVCodecContext *s, int thread_count);
111
int ff_thread_init(AVCodecContext *s);
112 112
void ff_thread_free(AVCodecContext *s);
113 113

  
114 114
#endif /* AVCODEC_THREAD_H */
libavcodec/utils.c
539 539
    avctx->frame_number = 0;
540 540

  
541 541
    if (HAVE_THREADS && !avctx->thread_opaque) {
542
        ret = ff_thread_init(avctx, avctx->thread_count);
542
        ret = ff_thread_init(avctx);
543 543
        if (ret < 0) {
544 544
            goto free_and_end;
545 545
        }
......
1147 1147
#endif
1148 1148

  
1149 1149
#if !HAVE_THREADS
1150
int ff_thread_init(AVCodecContext *s, int thread_count){
1151
    s->thread_count = thread_count;
1150
int ff_thread_init(AVCodecContext *s){
1152 1151
    return -1;
1153 1152
}
1154 1153
#endif
......
1291 1290

  
1292 1291
int avcodec_thread_init(AVCodecContext *s, int thread_count)
1293 1292
{
1294
    return ff_thread_init(s, thread_count);
1293
    s->thread_count = thread_count;
1294
    return ff_thread_init(s);
1295 1295
}
1296 1296

  
1297 1297
void avcodec_thread_free(AVCodecContext *s)
libavcodec/w32thread.c
125 125
    avcodec_thread_execute(s, NULL, arg, ret, count, 0);
126 126
}
127 127

  
128
int ff_thread_init(AVCodecContext *s, int thread_count){
128
int ff_thread_init(AVCodecContext *s){
129 129
    int i;
130 130
    ThreadContext *c;
131 131
    uint32_t threadid;
......
135 135
        return 0;
136 136
    }
137 137

  
138
    s->thread_count= thread_count;
139 138
    s->active_thread_type= FF_THREAD_SLICE;
140 139

  
141
    if (thread_count <= 1)
140
    if (s->thread_count <= 1)
142 141
        return 0;
143 142

  
144 143
    assert(!s->thread_opaque);
145
    c= av_mallocz(sizeof(ThreadContext)*thread_count);
144
    c= av_mallocz(sizeof(ThreadContext)*s->thread_count);
146 145
    s->thread_opaque= c;
147 146
    if(!(c[0].work_sem = CreateSemaphore(NULL, 0, INT_MAX, NULL)))
148 147
        goto fail;
......
151 150
    if(!(c[0].done_sem = CreateSemaphore(NULL, 0, INT_MAX, NULL)))
152 151
        goto fail;
153 152

  
154
    for(i=0; i<thread_count; i++){
153
    for(i=0; i<s->thread_count; i++){
155 154
//printf("init semaphors %d\n", i); fflush(stdout);
156 155
        c[i].avctx= s;
157 156
        c[i].work_sem = c[0].work_sem;

Also available in: Unified diff