diff options
author | Loren Merritt <lorenm@u.washington.edu> | 2006-03-23 20:16:36 +0000 |
---|---|---|
committer | Loren Merritt <lorenm@u.washington.edu> | 2006-03-23 20:16:36 +0000 |
commit | 513fbd8e5ab9ca266394112b177a40b6eb1d8208 (patch) | |
tree | 2cc484711e334dcf1633a231212758ed3b2d2bff /libavcodec/h264.c | |
parent | 7e815047e5621683ab7a91a23c93906cf916ff36 (diff) | |
download | ffmpeg-513fbd8e5ab9ca266394112b177a40b6eb1d8208.tar.gz |
prefetch pixels for future motion compensation. 2-5% faster h264.
Originally committed as revision 5203 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/h264.c')
-rw-r--r-- | libavcodec/h264.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c index c419d7230c..a972aeb03c 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -2752,6 +2752,22 @@ static inline void mc_part(H264Context *h, int n, int square, int chroma_height, x_offset, y_offset, qpix_put, chroma_put, qpix_avg, chroma_avg, list0, list1); } +static inline void prefetch_motion(H264Context *h, int list){ + /* fetch pixels for estimated mv 4 macroblocks ahead + * optimized for 64byte cache lines */ + MpegEncContext * const s = &h->s; + const int refn = h->ref_cache[list][scan8[0]]; + if(refn >= 0){ + const int mx= (h->mv_cache[list][scan8[0]][0]>>2) + 16*s->mb_x + 8; + const int my= (h->mv_cache[list][scan8[0]][1]>>2) + 16*s->mb_y; + uint8_t **src= h->ref_list[list][refn].data; + int off= mx + (my + (s->mb_x&3)*4)*s->linesize + 64; + s->dsp.prefetch(src[0]+off, s->linesize, 4); + off= (mx>>1) + ((my>>1) + (s->mb_x&7))*s->uvlinesize + 64; + s->dsp.prefetch(src[1]+off, src[2]-src[1], 2); + } +} + static void hl_motion(H264Context *h, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, qpel_mc_func (*qpix_put)[16], h264_chroma_mc_func (*chroma_put), qpel_mc_func (*qpix_avg)[16], h264_chroma_mc_func (*chroma_avg), @@ -2762,6 +2778,8 @@ static void hl_motion(H264Context *h, uint8_t *dest_y, uint8_t *dest_cb, uint8_t assert(IS_INTER(mb_type)); + prefetch_motion(h, 0); + if(IS_16X16(mb_type)){ mc_part(h, 0, 1, 8, 0, dest_y, dest_cb, dest_cr, 0, 0, qpix_put[0], chroma_put[0], qpix_avg[0], chroma_avg[0], @@ -2833,6 +2851,8 @@ static void hl_motion(H264Context *h, uint8_t *dest_y, uint8_t *dest_cb, uint8_t } } } + + prefetch_motion(h, 1); } static void decode_init_vlc(H264Context *h){ |