Commit f69f4036 authored by Mans Rullgard's avatar Mans Rullgard

mpegvideo: reduce excessive inlining of mpeg_motion()

The main benefit of inlining this function is from constant
propagation for the 'field_based' argument.  Instead of inlining
all calls, create two versions of the function for field_based
values of 0 and 1.
Signed-off-by: 's avatarMans Rullgard <mans@mansr.com>
parent 7a851153
...@@ -339,21 +339,39 @@ if(s->quarter_sample) ...@@ -339,21 +339,39 @@ if(s->quarter_sample)
} }
} }
/* apply one mpeg motion vector to the three components */ /* apply one mpeg motion vector to the three components */
static av_always_inline static void mpeg_motion(MpegEncContext *s,
void mpeg_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int field_select, uint8_t **ref_picture,
int field_based, int bottom_field, int field_select, op_pixels_func (*pix_op)[4],
uint8_t **ref_picture, op_pixels_func (*pix_op)[4], int motion_x, int motion_y, int h, int mb_y)
int motion_x, int motion_y, int h, int mb_y)
{ {
#if !CONFIG_SMALL #if !CONFIG_SMALL
if(s->out_format == FMT_MPEG1) if(s->out_format == FMT_MPEG1)
mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, field_based, mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, 0, 0,
field_select, ref_picture, pix_op,
motion_x, motion_y, h, 1, mb_y);
else
#endif
mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, 0, 0,
field_select, ref_picture, pix_op,
motion_x, motion_y, h, 0, mb_y);
}
static void mpeg_motion_field(MpegEncContext *s, uint8_t *dest_y,
uint8_t *dest_cb, uint8_t *dest_cr,
int bottom_field, int field_select,
uint8_t **ref_picture,
op_pixels_func (*pix_op)[4],
int motion_x, int motion_y, int h, int mb_y)
{
#if !CONFIG_SMALL
if(s->out_format == FMT_MPEG1)
mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, 1,
bottom_field, field_select, ref_picture, pix_op, bottom_field, field_select, ref_picture, pix_op,
motion_x, motion_y, h, 1, mb_y); motion_x, motion_y, h, 1, mb_y);
else else
#endif #endif
mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, field_based, mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, 1,
bottom_field, field_select, ref_picture, pix_op, bottom_field, field_select, ref_picture, pix_op,
motion_x, motion_y, h, 0, mb_y); motion_x, motion_y, h, 0, mb_y);
} }
...@@ -708,8 +726,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s, ...@@ -708,8 +726,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
s->mv[dir][0][0], s->mv[dir][0][1], 16); s->mv[dir][0][0], s->mv[dir][0][1], 16);
}else }else
{ {
mpeg_motion(s, dest_y, dest_cb, dest_cr, mpeg_motion(s, dest_y, dest_cb, dest_cr, 0,
0, 0, 0,
ref_picture, pix_op, ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y); s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y);
} }
...@@ -782,15 +799,15 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s, ...@@ -782,15 +799,15 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
} }
}else{ }else{
/* top field */ /* top field */
mpeg_motion(s, dest_y, dest_cb, dest_cr, mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
1, 0, s->field_select[dir][0], 0, s->field_select[dir][0],
ref_picture, pix_op, ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 8, mb_y); s->mv[dir][0][0], s->mv[dir][0][1], 8, mb_y);
/* bottom field */ /* bottom field */
mpeg_motion(s, dest_y, dest_cb, dest_cr, mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
1, 1, s->field_select[dir][1], 1, s->field_select[dir][1],
ref_picture, pix_op, ref_picture, pix_op,
s->mv[dir][1][0], s->mv[dir][1][1], 8, mb_y); s->mv[dir][1][0], s->mv[dir][1][1], 8, mb_y);
} }
} else { } else {
if(s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != AV_PICTURE_TYPE_B && !s->first_field){ if(s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != AV_PICTURE_TYPE_B && !s->first_field){
...@@ -798,7 +815,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s, ...@@ -798,7 +815,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
} }
mpeg_motion(s, dest_y, dest_cb, dest_cr, mpeg_motion(s, dest_y, dest_cb, dest_cr,
0, 0, s->field_select[dir][0], s->field_select[dir][0],
ref_picture, pix_op, ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y>>1); s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y>>1);
} }
...@@ -815,7 +832,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s, ...@@ -815,7 +832,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
} }
mpeg_motion(s, dest_y, dest_cb, dest_cr, mpeg_motion(s, dest_y, dest_cb, dest_cr,
0, 0, s->field_select[dir][i], s->field_select[dir][i],
ref2picture, pix_op, ref2picture, pix_op,
s->mv[dir][i][0], s->mv[dir][i][1] + 16*i, 8, mb_y>>1); s->mv[dir][i][0], s->mv[dir][i][1] + 16*i, 8, mb_y>>1);
...@@ -829,17 +846,17 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s, ...@@ -829,17 +846,17 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
for(i=0; i<2; i++){ for(i=0; i<2; i++){
int j; int j;
for(j=0; j<2; j++){ for(j=0; j<2; j++){
mpeg_motion(s, dest_y, dest_cb, dest_cr, mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
1, j, j^i, j, j^i, ref_picture, pix_op,
ref_picture, pix_op, s->mv[dir][2*i + j][0],
s->mv[dir][2*i + j][0], s->mv[dir][2*i + j][1], 8, mb_y); s->mv[dir][2*i + j][1], 8, mb_y);
} }
pix_op = s->dsp.avg_pixels_tab; pix_op = s->dsp.avg_pixels_tab;
} }
}else{ }else{
for(i=0; i<2; i++){ for(i=0; i<2; i++){
mpeg_motion(s, dest_y, dest_cb, dest_cr, mpeg_motion(s, dest_y, dest_cb, dest_cr,
0, 0, s->picture_structure != i+1, s->picture_structure != i+1,
ref_picture, pix_op, ref_picture, pix_op,
s->mv[dir][2*i][0],s->mv[dir][2*i][1],16, mb_y>>1); s->mv[dir][2*i][0],s->mv[dir][2*i][1],16, mb_y>>1);
......
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