comparison mpegvideo_enc.c @ 8129:a9734fe0811e libavcodec

Making it easier to send arbitrary structures as work orders to MT workers
author romansh
date Wed, 12 Nov 2008 17:47:23 +0000
parents a0f9045e0a82
children f88ab1c3e333
comparison
equal deleted inserted replaced
8128:e2241dd85c65 8129:a9734fe0811e
1915 +sse(s, s->new_picture.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], w>>1, h>>1, s->uvlinesize) 1915 +sse(s, s->new_picture.data[1] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[1], w>>1, h>>1, s->uvlinesize)
1916 +sse(s, s->new_picture.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], w>>1, h>>1, s->uvlinesize); 1916 +sse(s, s->new_picture.data[2] + s->mb_x*8 + s->mb_y*s->uvlinesize*8,s->dest[2], w>>1, h>>1, s->uvlinesize);
1917 } 1917 }
1918 1918
1919 static int pre_estimate_motion_thread(AVCodecContext *c, void *arg){ 1919 static int pre_estimate_motion_thread(AVCodecContext *c, void *arg){
1920 MpegEncContext *s= arg; 1920 MpegEncContext *s= *(void**)arg;
1921 1921
1922 1922
1923 s->me.pre_pass=1; 1923 s->me.pre_pass=1;
1924 s->me.dia_size= s->avctx->pre_dia_size; 1924 s->me.dia_size= s->avctx->pre_dia_size;
1925 s->first_slice_line=1; 1925 s->first_slice_line=1;
1934 1934
1935 return 0; 1935 return 0;
1936 } 1936 }
1937 1937
1938 static int estimate_motion_thread(AVCodecContext *c, void *arg){ 1938 static int estimate_motion_thread(AVCodecContext *c, void *arg){
1939 MpegEncContext *s= arg; 1939 MpegEncContext *s= *(void**)arg;
1940 1940
1941 ff_check_alignment(); 1941 ff_check_alignment();
1942 1942
1943 s->me.dia_size= s->avctx->dia_size; 1943 s->me.dia_size= s->avctx->dia_size;
1944 s->first_slice_line=1; 1944 s->first_slice_line=1;
1961 } 1961 }
1962 return 0; 1962 return 0;
1963 } 1963 }
1964 1964
1965 static int mb_var_thread(AVCodecContext *c, void *arg){ 1965 static int mb_var_thread(AVCodecContext *c, void *arg){
1966 MpegEncContext *s= arg; 1966 MpegEncContext *s= *(void**)arg;
1967 int mb_x, mb_y; 1967 int mb_x, mb_y;
1968 1968
1969 ff_check_alignment(); 1969 ff_check_alignment();
1970 1970
1971 for(mb_y=s->start_mb_y; mb_y < s->end_mb_y; mb_y++) { 1971 for(mb_y=s->start_mb_y; mb_y < s->end_mb_y; mb_y++) {
2003 if((s->flags&CODEC_FLAG_PASS1) && !s->partitioned_frame) 2003 if((s->flags&CODEC_FLAG_PASS1) && !s->partitioned_frame)
2004 s->misc_bits+= get_bits_diff(s); 2004 s->misc_bits+= get_bits_diff(s);
2005 } 2005 }
2006 2006
2007 static int encode_thread(AVCodecContext *c, void *arg){ 2007 static int encode_thread(AVCodecContext *c, void *arg){
2008 MpegEncContext *s= arg; 2008 MpegEncContext *s= *(void**)arg;
2009 int mb_x, mb_y, pdif = 0; 2009 int mb_x, mb_y, pdif = 0;
2010 int chr_h= 16>>s->chroma_y_shift; 2010 int chr_h= 16>>s->chroma_y_shift;
2011 int i, j; 2011 int i, j;
2012 MpegEncContext best_s, backup_s; 2012 MpegEncContext best_s, backup_s;
2013 uint8_t bit_buf[2][MAX_MB_BYTES]; 2013 uint8_t bit_buf[2][MAX_MB_BYTES];
2777 if(s->pict_type != FF_I_TYPE){ 2777 if(s->pict_type != FF_I_TYPE){
2778 s->lambda = (s->lambda * s->avctx->me_penalty_compensation + 128)>>8; 2778 s->lambda = (s->lambda * s->avctx->me_penalty_compensation + 128)>>8;
2779 s->lambda2= (s->lambda2* (int64_t)s->avctx->me_penalty_compensation + 128)>>8; 2779 s->lambda2= (s->lambda2* (int64_t)s->avctx->me_penalty_compensation + 128)>>8;
2780 if(s->pict_type != FF_B_TYPE && s->avctx->me_threshold==0){ 2780 if(s->pict_type != FF_B_TYPE && s->avctx->me_threshold==0){
2781 if((s->avctx->pre_me && s->last_non_b_pict_type==FF_I_TYPE) || s->avctx->pre_me==2){ 2781 if((s->avctx->pre_me && s->last_non_b_pict_type==FF_I_TYPE) || s->avctx->pre_me==2){
2782 s->avctx->execute(s->avctx, pre_estimate_motion_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count); 2782 s->avctx->execute(s->avctx, pre_estimate_motion_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count, sizeof(void*));
2783 } 2783 }
2784 } 2784 }
2785 2785
2786 s->avctx->execute(s->avctx, estimate_motion_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count); 2786 s->avctx->execute(s->avctx, estimate_motion_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count, sizeof(void*));
2787 }else /* if(s->pict_type == FF_I_TYPE) */{ 2787 }else /* if(s->pict_type == FF_I_TYPE) */{
2788 /* I-Frame */ 2788 /* I-Frame */
2789 for(i=0; i<s->mb_stride*s->mb_height; i++) 2789 for(i=0; i<s->mb_stride*s->mb_height; i++)
2790 s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA; 2790 s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
2791 2791
2792 if(!s->fixed_qscale){ 2792 if(!s->fixed_qscale){
2793 /* finding spatial complexity for I-frame rate control */ 2793 /* finding spatial complexity for I-frame rate control */
2794 s->avctx->execute(s->avctx, mb_var_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count); 2794 s->avctx->execute(s->avctx, mb_var_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count, sizeof(void*));
2795 } 2795 }
2796 } 2796 }
2797 for(i=1; i<s->avctx->thread_count; i++){ 2797 for(i=1; i<s->avctx->thread_count; i++){
2798 merge_context_after_me(s, s->thread_context[i]); 2798 merge_context_after_me(s, s->thread_context[i]);
2799 } 2799 }
2929 s->header_bits= bits - s->last_bits; 2929 s->header_bits= bits - s->last_bits;
2930 2930
2931 for(i=1; i<s->avctx->thread_count; i++){ 2931 for(i=1; i<s->avctx->thread_count; i++){
2932 update_duplicate_context_after_me(s->thread_context[i], s); 2932 update_duplicate_context_after_me(s->thread_context[i], s);
2933 } 2933 }
2934 s->avctx->execute(s->avctx, encode_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count); 2934 s->avctx->execute(s->avctx, encode_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count, sizeof(void*));
2935 for(i=1; i<s->avctx->thread_count; i++){ 2935 for(i=1; i<s->avctx->thread_count; i++){
2936 merge_context_after_encode(s, s->thread_context[i]); 2936 merge_context_after_encode(s, s->thread_context[i]);
2937 } 2937 }
2938 emms_c(); 2938 emms_c();
2939 return 0; 2939 return 0;