Revision d375c104 libavcodec/mpegvideo_enc.c

View differences:

libavcodec/mpegvideo_enc.c
36 36
#include "mjpegenc.h"
37 37
#include "msmpeg4.h"
38 38
#include "faandct.h"
39
#include "thread.h"
39 40
#include "aandcttab.h"
40 41
#include "flv.h"
41 42
#include "mpeg4video.h"
......
1238 1239
{
1239 1240
    MpegEncContext *s = avctx->priv_data;
1240 1241
    AVFrame *pic_arg = data;
1241
    int i, stuffing_count;
1242
    int i, stuffing_count, context_count = avctx->active_thread_type&FF_THREAD_SLICE ? avctx->thread_count : 1;
1242 1243

  
1243
    for(i=0; i<avctx->thread_count; i++){
1244
    for(i=0; i<context_count; i++){
1244 1245
        int start_y= s->thread_context[i]->start_mb_y;
1245 1246
        int   end_y= s->thread_context[i]->  end_mb_y;
1246 1247
        int h= s->mb_height;
......
1304 1305
                    s->last_non_b_time= s->time - s->pp_time;
1305 1306
                }
1306 1307
//                av_log(NULL, AV_LOG_ERROR, "R:%d ", s->next_lambda);
1307
                for(i=0; i<avctx->thread_count; i++){
1308
                for(i=0; i<context_count; i++){
1308 1309
                    PutBitContext *pb= &s->thread_context[i]->pb;
1309 1310
                    init_put_bits(pb, pb->buf, pb->buf_end - pb->buf);
1310 1311
                }
......
2771 2772
{
2772 2773
    int i;
2773 2774
    int bits;
2775
    int context_count = s->avctx->active_thread_type&FF_THREAD_SLICE ? s->avctx->thread_count : 1;
2774 2776

  
2775 2777
    s->picture_number = picture_number;
2776 2778

  
......
2810 2812
    }
2811 2813

  
2812 2814
    s->mb_intra=0; //for the rate distortion & bit compare functions
2813
    for(i=1; i<s->avctx->thread_count; i++){
2815
    for(i=1; i<context_count; i++){
2814 2816
        ff_update_duplicate_context(s->thread_context[i], s);
2815 2817
    }
2816 2818

  
......
2823 2825
        s->lambda2= (s->lambda2* (int64_t)s->avctx->me_penalty_compensation + 128)>>8;
2824 2826
        if(s->pict_type != FF_B_TYPE && s->avctx->me_threshold==0){
2825 2827
            if((s->avctx->pre_me && s->last_non_b_pict_type==FF_I_TYPE) || s->avctx->pre_me==2){
2826
                s->avctx->execute(s->avctx, pre_estimate_motion_thread, &s->thread_context[0], NULL, s->avctx->thread_count, sizeof(void*));
2828
                s->avctx->execute(s->avctx, pre_estimate_motion_thread, &s->thread_context[0], NULL, context_count, sizeof(void*));
2827 2829
            }
2828 2830
        }
2829 2831

  
2830
        s->avctx->execute(s->avctx, estimate_motion_thread, &s->thread_context[0], NULL, s->avctx->thread_count, sizeof(void*));
2832
        s->avctx->execute(s->avctx, estimate_motion_thread, &s->thread_context[0], NULL, context_count, sizeof(void*));
2831 2833
    }else /* if(s->pict_type == FF_I_TYPE) */{
2832 2834
        /* I-Frame */
2833 2835
        for(i=0; i<s->mb_stride*s->mb_height; i++)
......
2835 2837

  
2836 2838
        if(!s->fixed_qscale){
2837 2839
            /* finding spatial complexity for I-frame rate control */
2838
            s->avctx->execute(s->avctx, mb_var_thread, &s->thread_context[0], NULL, s->avctx->thread_count, sizeof(void*));
2840
            s->avctx->execute(s->avctx, mb_var_thread, &s->thread_context[0], NULL, context_count, sizeof(void*));
2839 2841
        }
2840 2842
    }
2841
    for(i=1; i<s->avctx->thread_count; i++){
2843
    for(i=1; i<context_count; i++){
2842 2844
        merge_context_after_me(s, s->thread_context[i]);
2843 2845
    }
2844 2846
    s->current_picture.mc_mb_var_sum= s->current_picture_ptr->mc_mb_var_sum= s->me.mc_mb_var_sum_temp;
......
2974 2976
    bits= put_bits_count(&s->pb);
2975 2977
    s->header_bits= bits - s->last_bits;
2976 2978

  
2977
    for(i=1; i<s->avctx->thread_count; i++){
2979
    for(i=1; i<context_count; i++){
2978 2980
        update_duplicate_context_after_me(s->thread_context[i], s);
2979 2981
    }
2980
    s->avctx->execute(s->avctx, encode_thread, &s->thread_context[0], NULL, s->avctx->thread_count, sizeof(void*));
2981
    for(i=1; i<s->avctx->thread_count; i++){
2982
    s->avctx->execute(s->avctx, encode_thread, &s->thread_context[0], NULL, context_count, sizeof(void*));
2983
    for(i=1; i<context_count; i++){
2982 2984
        merge_context_after_encode(s, s->thread_context[i]);
2983 2985
    }
2984 2986
    emms_c();

Also available in: Unified diff