Browse Source

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: Mans Rullgard <mans@mansr.com>
tags/n1.0
Mans Rullgard 12 years ago
parent
commit
f69f4036f8
1 changed files with 42 additions and 25 deletions
  1. +42
    -25
      libavcodec/mpegvideo_motion.c

+ 42
- 25
libavcodec/mpegvideo_motion.c View File

@@ -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
void mpeg_motion(MpegEncContext *s,
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
int field_based, 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)
static void mpeg_motion(MpegEncContext *s,
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
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 !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,
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,
0, 0, 0,
mpeg_motion(s, dest_y, dest_cb, dest_cr, 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,
} }
}else{ }else{
/* top field */ /* top field */
mpeg_motion(s, dest_y, dest_cb, dest_cr,
1, 0, s->field_select[dir][0],
ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 8, mb_y);
mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
0, s->field_select[dir][0],
ref_picture, pix_op,
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,
1, 1, s->field_select[dir][1],
ref_picture, pix_op,
s->mv[dir][1][0], s->mv[dir][1][1], 8, mb_y);
mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
1, s->field_select[dir][1],
ref_picture, pix_op,
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,
} }


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,
} }


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,
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,
1, j, j^i,
ref_picture, pix_op,
s->mv[dir][2*i + j][0], s->mv[dir][2*i + j][1], 8, mb_y);
mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
j, j^i, ref_picture, pix_op,
s->mv[dir][2*i + j][0],
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);




Loading…
Cancel
Save