skip motion estimation and encoding of non direct-0,0 MBs if the next MB is skiped (mpeg4 doesnt allow such MBs and in the past we did ME and encoding until at the end we droped them, so this should be faster though i didnt benchmark it, benchmark welcome)

Originally committed as revision 7343 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Michael Niedermayer 2006-12-21 15:20:02 +00:00
parent 59743d16c7
commit 2f16af0667
4 changed files with 31 additions and 9 deletions

View File

@ -1843,6 +1843,18 @@ void ff_estimate_b_frame_motion(MpegEncContext * s,
get_limits(s, 16*mb_x, 16*mb_y); get_limits(s, 16*mb_x, 16*mb_y);
c->skip=0; c->skip=0;
if(s->codec_id == CODEC_ID_MPEG4 && s->next_picture.mbskip_table[xy]){
int score= direct_search(s, mb_x, mb_y); //FIXME just check 0,0
score= ((unsigned)(score*score + 128*256))>>16;
c->mc_mb_var_sum_temp += score;
s->current_picture.mc_mb_var[mb_y*s->mb_stride + mb_x] = score; //FIXME use SSE
s->mb_type[mb_y*s->mb_stride + mb_x]= CANDIDATE_MB_TYPE_DIRECT0;
return;
}
if(c->avctx->me_threshold){ if(c->avctx->me_threshold){
int vard= check_input_motion(s, mb_x, mb_y, 0); int vard= check_input_motion(s, mb_x, mb_y, 0);

View File

@ -5226,8 +5226,8 @@ static int encode_thread(AVCodecContext *c, void *arg){
} }
} }
if(s->flags & CODEC_FLAG_QP_RD){ if((s->flags & CODEC_FLAG_QP_RD) && dmin < INT_MAX){
if(best_s.mv_type==MV_TYPE_16X16 && !(best_s.mv_dir&MV_DIRECT)){ if(best_s.mv_type==MV_TYPE_16X16){ //FIXME move 4mv after QPRD
const int last_qp= backup_s.qscale; const int last_qp= backup_s.qscale;
int qpi, qp, dc[6]; int qpi, qp, dc[6];
DCTELEM ac[6][16]; DCTELEM ac[6][16];
@ -5283,6 +5283,14 @@ static int encode_thread(AVCodecContext *c, void *arg){
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb, encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,
&dmin, &next_block, mx, my); &dmin, &next_block, mx, my);
} }
if(mb_type&CANDIDATE_MB_TYPE_DIRECT0){
backup_s.dquant = 0;
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
s->mb_intra= 0;
ff_mpeg4_set_direct_mv(s, 0, 0);
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
s->current_picture.qscale_table[xy]= best_s.qscale; s->current_picture.qscale_table[xy]= best_s.qscale;
copy_context_after_encode(s, &best_s, -1); copy_context_after_encode(s, &best_s, -1);

View File

@ -402,6 +402,8 @@ typedef struct MpegEncContext {
#define CANDIDATE_MB_TYPE_BACKWARD_I 0x400 #define CANDIDATE_MB_TYPE_BACKWARD_I 0x400
#define CANDIDATE_MB_TYPE_BIDIR_I 0x800 #define CANDIDATE_MB_TYPE_BIDIR_I 0x800
#define CANDIDATE_MB_TYPE_DIRECT0 0x1000
int block_index[6]; ///< index to current MB in block based arrays with edges int block_index[6]; ///< index to current MB in block based arrays with edges
int block_wrap[6]; int block_wrap[6];
uint8_t *dest[3]; uint8_t *dest[3];

View File

@ -67,18 +67,18 @@ a1323da0c8b437cd6961f8c90451880b *./data/a-huffyuv.avi
6455232 ./data/a-huffyuv.avi 6455232 ./data/a-huffyuv.avi
dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv
stddev: 0.00 PSNR:99.99 bytes:7602176 stddev: 0.00 PSNR:99.99 bytes:7602176
1fd3bddc95fa01ee4c4b383373803c67 *./data/a-mpeg4-rc.avi 968ca132d8cf46f84e657abcf8473b7c *./data/a-mpeg4-rc.avi
227936 ./data/a-mpeg4-rc.avi 227934 ./data/a-mpeg4-rc.avi
fa9079e35ff819c39656de95319846fb *./data/out.yuv 895773fe8250c806a0d1592a6dd12401 *./data/out.yuv
stddev: 4.24 PSNR:35.56 bytes:7602176 stddev: 4.24 PSNR:35.56 bytes:7602176
9001cf571eb7f26fa5592bdec6538583 *./data/a-mpeg4-adv.avi 9001cf571eb7f26fa5592bdec6538583 *./data/a-mpeg4-adv.avi
173590 ./data/a-mpeg4-adv.avi 173590 ./data/a-mpeg4-adv.avi
699edf05648fdc42196b7bebef9be269 *./data/out.yuv 699edf05648fdc42196b7bebef9be269 *./data/out.yuv
stddev: 4.84 PSNR:34.41 bytes:7602176 stddev: 4.84 PSNR:34.41 bytes:7602176
7006aa0ad8643348ec0d6d87bf03202c *./data/a-mpeg4-qprd.avi edd969be2816c13ae078b7a0416a5715 *./data/a-mpeg4-qprd.avi
235016 ./data/a-mpeg4-qprd.avi 234852 ./data/a-mpeg4-qprd.avi
224969c07440a23b376521c484936e75 *./data/out.yuv 51fa46add28e145c1a5ce6b27a4c57b8 *./data/out.yuv
stddev: 4.24 PSNR:35.56 bytes:7602176 stddev: 4.24 PSNR:35.57 bytes:7602176
7ecfbb848740d316e2fcf573b32cb848 *./data/a-mpeg4-adap.avi 7ecfbb848740d316e2fcf573b32cb848 *./data/a-mpeg4-adap.avi
205454 ./data/a-mpeg4-adap.avi 205454 ./data/a-mpeg4-adap.avi
c9225addf2e620e0094d26e805693af1 *./data/out.yuv c9225addf2e620e0094d26e805693af1 *./data/out.yuv