Commit 65a24d0b authored by Michael Niedermayer's avatar Michael Niedermayer

optimization & bugfix extracted from the 4k line diff between ffmpeg 0.4.7 and...

optimization & bugfix extracted from the 4k line diff between ffmpeg 0.4.7 and http://www.alicestreet.com/ffh263.html
the other parts of the diff where
1. spelling fixes (rejected as only a small part of it could be applied automatically)
2. cosmetics (reindention, function reordering, var renaming, ...) with bugs (rejected)
3. rtp related stuff (rejetced as it breaks several codecs)
4. some changes to the intra/inter decission & scene change detection (quality tests needed first)

Originally committed as revision 2721 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 7a62e94a
...@@ -1130,6 +1130,8 @@ void h263_encode_mb(MpegEncContext * s, ...@@ -1130,6 +1130,8 @@ void h263_encode_mb(MpegEncContext * s,
s->misc_bits++; s->misc_bits++;
s->last_bits++; s->last_bits++;
} }
s->skip_count++;
return; return;
} }
put_bits(&s->pb, 1, 0); /* mb coded */ put_bits(&s->pb, 1, 0); /* mb coded */
...@@ -2032,7 +2034,7 @@ static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n) ...@@ -2032,7 +2034,7 @@ static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n)
if (level == 128) //FIXME check rv10 if (level == 128) //FIXME check rv10
put_bits(&s->pb, 8, 0xff); put_bits(&s->pb, 8, 0xff);
else else
put_bits(&s->pb, 8, level & 0xff); put_bits(&s->pb, 8, level);
i = 1; i = 1;
} else { } else {
i = 0; i = 0;
...@@ -2102,7 +2104,7 @@ static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n) ...@@ -2102,7 +2104,7 @@ static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n)
assert(slevel != 0); assert(slevel != 0);
if(slevel < 128 && slevel > -128) if(level < 128)
put_bits(&s->pb, 8, slevel & 0xff); put_bits(&s->pb, 8, slevel & 0xff);
else{ else{
put_bits(&s->pb, 8, 128); put_bits(&s->pb, 8, 128);
...@@ -2110,8 +2112,7 @@ static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n) ...@@ -2110,8 +2112,7 @@ static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n)
put_bits(&s->pb, 6, (slevel>>5)&0x3f); put_bits(&s->pb, 6, (slevel>>5)&0x3f);
} }
}else{ }else{
if(slevel < 64 && slevel > -64) { if(level < 64) { // 7-bit level
/* 7-bit level */
put_bits(&s->pb, 1, 0); put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, last); put_bits(&s->pb, 1, last);
put_bits(&s->pb, 6, run); put_bits(&s->pb, 6, run);
......
...@@ -3834,9 +3834,9 @@ static void encode_picture(MpegEncContext *s, int picture_number) ...@@ -3834,9 +3834,9 @@ static void encode_picture(MpegEncContext *s, int picture_number)
s->me.dia_size= s->avctx->pre_dia_size; s->me.dia_size= s->avctx->pre_dia_size;
for(mb_y=s->mb_height-1; mb_y >=0 ; mb_y--) { for(mb_y=s->mb_height-1; mb_y >=0 ; mb_y--) {
s->mb_y = mb_y;
for(mb_x=s->mb_width-1; mb_x >=0 ; mb_x--) { for(mb_x=s->mb_width-1; mb_x >=0 ; mb_x--) {
s->mb_x = mb_x; s->mb_x = mb_x;
s->mb_y = mb_y;
ff_pre_estimate_p_frame_motion(s, mb_x, mb_y); ff_pre_estimate_p_frame_motion(s, mb_x, mb_y);
} }
} }
...@@ -3846,13 +3846,13 @@ static void encode_picture(MpegEncContext *s, int picture_number) ...@@ -3846,13 +3846,13 @@ static void encode_picture(MpegEncContext *s, int picture_number)
s->me.dia_size= s->avctx->dia_size; s->me.dia_size= s->avctx->dia_size;
for(mb_y=0; mb_y < s->mb_height; mb_y++) { for(mb_y=0; mb_y < s->mb_height; mb_y++) {
s->mb_y = mb_y;
s->block_index[0]= s->block_wrap[0]*(mb_y*2 + 1) - 1; s->block_index[0]= s->block_wrap[0]*(mb_y*2 + 1) - 1;
s->block_index[1]= s->block_wrap[0]*(mb_y*2 + 1); s->block_index[1]= s->block_wrap[0]*(mb_y*2 + 1);
s->block_index[2]= s->block_wrap[0]*(mb_y*2 + 2) - 1; s->block_index[2]= s->block_wrap[0]*(mb_y*2 + 2) - 1;
s->block_index[3]= s->block_wrap[0]*(mb_y*2 + 2); s->block_index[3]= s->block_wrap[0]*(mb_y*2 + 2);
for(mb_x=0; mb_x < s->mb_width; mb_x++) { for(mb_x=0; mb_x < s->mb_width; mb_x++) {
s->mb_x = mb_x; s->mb_x = mb_x;
s->mb_y = mb_y;
s->block_index[0]+=2; s->block_index[0]+=2;
s->block_index[1]+=2; s->block_index[1]+=2;
s->block_index[2]+=2; s->block_index[2]+=2;
...@@ -3867,9 +3867,6 @@ static void encode_picture(MpegEncContext *s, int picture_number) ...@@ -3867,9 +3867,6 @@ static void encode_picture(MpegEncContext *s, int picture_number)
} }
}else /* if(s->pict_type == I_TYPE) */{ }else /* if(s->pict_type == I_TYPE) */{
/* I-Frame */ /* I-Frame */
//FIXME do we need to zero them?
memset(s->current_picture.motion_val[0][0], 0, sizeof(int16_t)*(s->mb_width*2 + 2)*(s->mb_height*2 + 2)*2);
memset(s->p_mv_table , 0, sizeof(int16_t)*(s->mb_stride)*s->mb_height*2);
for(i=0; i<s->mb_stride*s->mb_height; i++) for(i=0; i<s->mb_stride*s->mb_height; i++)
s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA; s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
...@@ -4026,6 +4023,8 @@ static void encode_picture(MpegEncContext *s, int picture_number) ...@@ -4026,6 +4023,8 @@ static void encode_picture(MpegEncContext *s, int picture_number)
break; break;
case FMT_H264: case FMT_H264:
break; break;
default:
assert(0);
} }
bits= get_bit_count(&s->pb); bits= get_bit_count(&s->pb);
s->header_bits= bits - s->last_bits; s->header_bits= bits - s->last_bits;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment