diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2003-10-23 13:22:20 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2003-10-23 13:22:20 +0000 |
commit | cf3bf5bbaa049667612a4b992239cc99dc31aee8 (patch) | |
tree | 1803ac6d760cce57fc0858e53b7a022f0e21bea6 /libavcodec/i386 | |
parent | 1745173bc56482e449253ef8d1032c6d5d48cab2 (diff) | |
download | ffmpeg-cf3bf5bbaa049667612a4b992239cc99dc31aee8.tar.gz |
minor mmx2 optimization if the dct
Originally committed as revision 2423 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/i386')
-rw-r--r-- | libavcodec/i386/dsputil_mmx.c | 9 | ||||
-rw-r--r-- | libavcodec/i386/fdct_mmx.c | 32 | ||||
-rw-r--r-- | libavcodec/i386/mpegvideo_mmx.c | 2 | ||||
-rw-r--r-- | libavcodec/i386/mpegvideo_mmx_template.c | 2 |
4 files changed, 40 insertions, 5 deletions
diff --git a/libavcodec/i386/dsputil_mmx.c b/libavcodec/i386/dsputil_mmx.c index c523be74a8..ec2b9cb18b 100644 --- a/libavcodec/i386/dsputil_mmx.c +++ b/libavcodec/i386/dsputil_mmx.c @@ -1603,8 +1603,13 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) const int idct_algo= avctx->idct_algo; #ifdef CONFIG_ENCODERS - if(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX) - c->fdct = ff_fdct_mmx; + if(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX){ + if(mm_flags & MM_MMXEXT){ + c->fdct = ff_fdct_mmx2; + }else{ + c->fdct = ff_fdct_mmx; + } + } #endif //CONFIG_ENCODERS if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SIMPLEMMX){ diff --git a/libavcodec/i386/fdct_mmx.c b/libavcodec/i386/fdct_mmx.c index 0b3d4d360c..eb78f38ea2 100644 --- a/libavcodec/i386/fdct_mmx.c +++ b/libavcodec/i386/fdct_mmx.c @@ -210,14 +210,19 @@ static always_inline void fdct_col(const int16_t *in, int16_t *out, int offset) movq_r2m(mm3, *(out + offset + 7 * 8)); } -static always_inline void fdct_row(const int16_t *in, int16_t *out, const int16_t *table) +static always_inline void fdct_row(const int16_t *in, int16_t *out, const int16_t *table, int mmx2) { + if(mmx2){ + pshufw_m2r(*(in + 4), mm5, 0x1B); + movq_m2r(*(in + 0), mm0); + }else{ movd_m2r(*(in + 6), mm5); punpcklwd_m2r(*(in + 4), mm5); movq_r2r(mm5, mm2); psrlq_i2r(0x20, mm5); movq_m2r(*(in + 0), mm0); punpcklwd_r2r(mm2, mm5); + } movq_r2r(mm0, mm1); paddsw_r2r(mm5, mm0); psubsw_r2r(mm5, mm1); @@ -283,7 +288,30 @@ void ff_fdct_mmx(int16_t *block) table = tab_frw_01234567; out = block; for(i=8;i>0;i--) { - fdct_row(block1, out, table); + fdct_row(block1, out, table, 0); + block1 += 8; + table += 32; + out += 8; + } +} + +void ff_fdct_mmx2(int16_t *block) +{ + int64_t align_tmp[16] ATTR_ALIGN(8); + int16_t * const block_tmp= (int16_t*)align_tmp; + int16_t *block1, *out; + const int16_t *table; + int i; + + block1 = block_tmp; + fdct_col(block, block1, 0); + fdct_col(block, block1, 4); + + block1 = block_tmp; + table = tab_frw_01234567; + out = block; + for(i=8;i>0;i--) { + fdct_row(block1, out, table, 1); block1 += 8; table += 32; out += 8; diff --git a/libavcodec/i386/mpegvideo_mmx.c b/libavcodec/i386/mpegvideo_mmx.c index d2f477b7b3..d217e10249 100644 --- a/libavcodec/i386/mpegvideo_mmx.c +++ b/libavcodec/i386/mpegvideo_mmx.c @@ -490,11 +490,13 @@ static void draw_edges_mmx(uint8_t *buf, int wrap, int width, int height, int w) #undef HAVE_MMX2 #define RENAME(a) a ## _MMX +#define RENAMEl(a) a ## _mmx #include "mpegvideo_mmx_template.c" #define HAVE_MMX2 #undef RENAME #define RENAME(a) a ## _MMX2 +#define RENAMEl(a) a ## _mmx2 #include "mpegvideo_mmx_template.c" void MPV_common_init_mmx(MpegEncContext *s) diff --git a/libavcodec/i386/mpegvideo_mmx_template.c b/libavcodec/i386/mpegvideo_mmx_template.c index 249f32493b..2728a8dd95 100644 --- a/libavcodec/i386/mpegvideo_mmx_template.c +++ b/libavcodec/i386/mpegvideo_mmx_template.c @@ -43,7 +43,7 @@ static int RENAME(dct_quantize)(MpegEncContext *s, assert((7&(int)(&temp_block[0])) == 0); //did gcc align it correctly? //s->fdct (block); - ff_fdct_mmx (block); //cant be anything else ... + RENAMEl(ff_fdct) (block); //cant be anything else ... if (s->mb_intra) { int dummy; |