Revision 043d2ff2

View differences:

doc/APIchanges
13 13

  
14 14
API changes, most recent first:
15 15

  
16
2011-02-09 - XXXXXXX - lavc 52.112.0 - avcodec_thread_init()
17
  Deprecate avcodec_thread_init()/avcodec_thread_free() use; instead
18
  set thread_count before calling avcodec_open.
19

  
16 20
2011-02-09 - 778b08a - lavc 52.111.0 - threading API
17 21
  Add CODEC_CAP_FRAME_THREADS with new restrictions on get_buffer()/
18 22
  release_buffer()/draw_horiz_band() callbacks for appropriate codecs.
ffmpeg.c
707 707
                choose_pixel_fmt(st, codec);
708 708
        }
709 709

  
710
        if(!st->codec->thread_count)
711
            st->codec->thread_count = 1;
712
        if(st->codec->thread_count>1)
713
            avcodec_thread_init(st->codec, st->codec->thread_count);
714

  
715 710
        if(st->codec->flags & CODEC_FLAG_BITEXACT)
716 711
            nopts = 1;
717 712

  
......
3248 3243
    for(i=0;i<ic->nb_streams;i++) {
3249 3244
        AVStream *st = ic->streams[i];
3250 3245
        AVCodecContext *dec = st->codec;
3251
        avcodec_thread_init(dec, thread_count);
3246
        dec->thread_count = thread_count;
3252 3247
        input_codecs = grow_array(input_codecs, sizeof(*input_codecs), &nb_input_codecs, nb_input_codecs + 1);
3253 3248
        switch (dec->codec_type) {
3254 3249
        case AVMEDIA_TYPE_AUDIO:
......
3406 3401
    ost->bitstream_filters = video_bitstream_filters;
3407 3402
    video_bitstream_filters= NULL;
3408 3403

  
3409
    avcodec_thread_init(st->codec, thread_count);
3404
    st->codec->thread_count= thread_count;
3410 3405

  
3411 3406
    video_enc = st->codec;
3412 3407

  
......
3553 3548
    ost->bitstream_filters = audio_bitstream_filters;
3554 3549
    audio_bitstream_filters= NULL;
3555 3550

  
3556
    avcodec_thread_init(st->codec, thread_count);
3551
    st->codec->thread_count= thread_count;
3557 3552

  
3558 3553
    audio_enc = st->codec;
3559 3554
    audio_enc->codec_type = AVMEDIA_TYPE_AUDIO;
ffplay.c
2257 2257
    avctx->skip_loop_filter= skip_loop_filter;
2258 2258
    avctx->error_recognition= error_recognition;
2259 2259
    avctx->error_concealment= error_concealment;
2260
    avcodec_thread_init(avctx, thread_count);
2260
    avctx->thread_count= thread_count;
2261 2261

  
2262 2262
    set_context_opts(avctx, avcodec_opts[avctx->codec_type], 0, codec);
2263 2263

  
libavcodec/avcodec.h
32 32
#include "libavutil/cpu.h"
33 33

  
34 34
#define LIBAVCODEC_VERSION_MAJOR 52
35
#define LIBAVCODEC_VERSION_MINOR 111
35
#define LIBAVCODEC_VERSION_MINOR 112
36 36
#define LIBAVCODEC_VERSION_MICRO  0
37 37

  
38 38
#define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
......
3656 3656

  
3657 3657
enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
3658 3658

  
3659
#if LIBAVCODEC_VERSION_MAJOR < 53
3660
/**
3661
 * @deprecated Set s->thread_count before calling avcodec_open() instead of calling this.
3662
 */
3663
attribute_deprecated
3659 3664
int avcodec_thread_init(AVCodecContext *s, int thread_count);
3660 3665
void avcodec_thread_free(AVCodecContext *s);
3666
#endif
3661 3667
int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
3662 3668
int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);
3663 3669
//FIXME func typedef
libavcodec/pthread.c
256 256
        if(pthread_create(&c->workers[i], NULL, worker, avctx)) {
257 257
           avctx->thread_count = i;
258 258
           pthread_mutex_unlock(&c->current_job_lock);
259
           avcodec_thread_free(avctx);
259
           ff_thread_free(avctx);
260 260
           return -1;
261 261
        }
262 262
    }
......
870 870
    }
871 871
}
872 872

  
873
int avcodec_thread_init(AVCodecContext *avctx, int thread_count)
873
int ff_thread_init(AVCodecContext *avctx, int thread_count)
874 874
{
875 875
    if (avctx->thread_opaque) {
876 876
        av_log(avctx, AV_LOG_ERROR, "avcodec_thread_init is ignored after avcodec_open\n");
......
891 891
    return 0;
892 892
}
893 893

  
894
void avcodec_thread_free(AVCodecContext *avctx)
894
void ff_thread_free(AVCodecContext *avctx)
895 895
{
896 896
    if (avctx->active_thread_type&FF_THREAD_FRAME)
897 897
        frame_thread_free(avctx, avctx->thread_count);
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);
112
void ff_thread_free(AVCodecContext *s);
113

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

  
542 542
    if (HAVE_THREADS && !avctx->thread_opaque) {
543
        ret = avcodec_thread_init(avctx, avctx->thread_count);
543
        ret = ff_thread_init(avctx, avctx->thread_count);
544 544
        if (ret < 0) {
545 545
            goto free_and_end;
546 546
        }
......
819 819
    }
820 820

  
821 821
    if (HAVE_THREADS && avctx->thread_opaque)
822
        avcodec_thread_free(avctx);
822
        ff_thread_free(avctx);
823 823
    if (avctx->codec && avctx->codec->close)
824 824
        avctx->codec->close(avctx);
825 825
    avcodec_default_free_buffers(avctx);
......
1180 1180
#endif
1181 1181

  
1182 1182
#if !HAVE_THREADS
1183
int avcodec_thread_init(AVCodecContext *s, int thread_count){
1183
int ff_thread_init(AVCodecContext *s, int thread_count){
1184 1184
    s->thread_count = thread_count;
1185 1185
    return -1;
1186 1186
}
......
1319 1319
}
1320 1320

  
1321 1321
#endif
1322

  
1323
#if LIBAVCODEC_VERSION_MAJOR < 53
1324

  
1325
int avcodec_thread_init(AVCodecContext *s, int thread_count)
1326
{
1327
    return ff_thread_init(s, thread_count);
1328
}
1329

  
1330
void avcodec_thread_free(AVCodecContext *s)
1331
{
1332
    return ff_thread_free(s);
1333
}
1334

  
1335
#endif
libavcodec/w32thread.c
69 69
}
70 70

  
71 71
/**
72
 * Free what has been allocated by avcodec_thread_init().
72
 * Free what has been allocated by ff_thread_init().
73 73
 * Must be called after decoding has finished, especially do not call while avcodec_thread_execute() is running.
74 74
 */
75
void avcodec_thread_free(AVCodecContext *s){
75
void ff_thread_free(AVCodecContext *s){
76 76
    ThreadContext *c= s->thread_opaque;
77 77
    int i;
78 78

  
......
124 124
    avcodec_thread_execute(s, NULL, arg, ret, count, 0);
125 125
}
126 126

  
127
int avcodec_thread_init(AVCodecContext *s, int thread_count){
127
int ff_thread_init(AVCodecContext *s, int thread_count){
128 128
    int i;
129 129
    ThreadContext *c;
130 130
    uint32_t threadid;
......
169 169

  
170 170
    return 0;
171 171
fail:
172
    avcodec_thread_free(s);
172
    ff_thread_free(s);
173 173
    return -1;
174 174
}

Also available in: Unified diff