diff options
author | Loren Merritt <lorenm@u.washington.edu> | 2006-03-23 21:54:46 +0000 |
---|---|---|
committer | Loren Merritt <lorenm@u.washington.edu> | 2006-03-23 21:54:46 +0000 |
commit | e77ef2755a98c70e5841e192cef69ad3079789de (patch) | |
tree | c2e9f08f41a378b3171110327862fcb73e146071 /libavcodec/mpegvideo.c | |
parent | 513fbd8e5ab9ca266394112b177a40b6eb1d8208 (diff) | |
download | ffmpeg-e77ef2755a98c70e5841e192cef69ad3079789de.tar.gz |
prefetch pixels for future motion compensation. 4-10% faster mpeg1/2/4 decoding (on an athlon-xp).
Originally committed as revision 5204 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mpegvideo.c')
-rw-r--r-- | libavcodec/mpegvideo.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index bfa58e826b..c4f83c9e80 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -3359,6 +3359,18 @@ static inline void chroma_4mv_motion_lowres(MpegEncContext *s, pix_op[lowres](dest_cr, ptr, s->uvlinesize, block_s, sx, sy); } +static inline void prefetch_motion(MpegEncContext *s, uint8_t **pix, int dir){ + /* fetch pixels for estimated mv 4 macroblocks ahead + * optimized for 64byte cache lines */ + const int shift = s->quarter_sample ? 2 : 1; + const int mx= (s->mv[dir][0][0]>>shift) + 16*s->mb_x + 8; + const int my= (s->mv[dir][0][1]>>shift) + 16*s->mb_y; + int off= mx + (my + (s->mb_x&3)*4)*s->linesize + 64; + s->dsp.prefetch(pix[0]+off, s->linesize, 4); + off= (mx>>1) + ((my>>1) + (s->mb_x&7))*s->uvlinesize + 64; + s->dsp.prefetch(pix[1]+off, pix[2]-pix[1], 2); +} + /** * motion compensation of a single macroblock * @param s context @@ -3383,6 +3395,8 @@ static inline void MPV_motion(MpegEncContext *s, mb_x = s->mb_x; mb_y = s->mb_y; + prefetch_motion(s, ref_picture, dir); + if(s->obmc && s->pict_type != B_TYPE){ int16_t mv_cache[4][4][2]; const int xy= s->mb_x + s->mb_y*s->mb_stride; |