From cd17285e6cecefbeb286adbba881eb26dbabec29 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 29 Sep 2010 14:04:39 +0000 Subject: [PATCH] Merge b_idx and edge variables, and optimize the ASM to directly load variables from memory locations/offsets depending on b_idx plus constants, rather than having gcc do this. This saves several lea calls and together saves about 10 cycles in h264_loop_filter_strength_mmx2(). Originally committed as revision 25256 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/x86/h264dsp_mmx.c | 100 +++++++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 46 deletions(-) diff --git a/libavcodec/x86/h264dsp_mmx.c b/libavcodec/x86/h264dsp_mmx.c index 92d08d90a..d449efdcc 100644 --- a/libavcodec/x86/h264dsp_mmx.c +++ b/libavcodec/x86/h264dsp_mmx.c @@ -69,33 +69,34 @@ static av_always_inline void h264_loop_filter_strength_iteration_mmx2(int16_t bS int mask_mv, int dir, const int d_idx, const uint64_t mask_dir) { - int b_idx, edge; - for( b_idx=12, edge=0; edge= limit "packsswb %%mm1, %%mm1 \n" "por %%mm1, %%mm0 \n" - ::"i"(d_idx), - "r"(ref[0]+b_idx), - "r"(mv[0]+b_idx), - "i"(d_idx*4), - "i"(d_idx*4+8) + ::"r"(ref), + "r"(mv), + "r"(b_idx), + "i"(d_idx+12), + "i"(d_idx*4+48), + "i"(d_idx*4+56) ); } } __asm__ volatile( - "movd (%0), %%mm1 \n" - "por %a1(%0), %%mm1 \n" // nnz[b] || nnz[bn] - ::"r"(nnz+b_idx), - "i"(d_idx) + "movd 12(%0,%1), %%mm1 \n" + "por %a2(%0,%1), %%mm1 \n" // nnz[b] || nnz[bn] + ::"r"(nnz), + "r"(b_idx), + "i"(d_idx+12) ); __asm__ volatile( "pminub %%mm7, %%mm1 \n" @@ -168,9 +172,11 @@ static av_always_inline void h264_loop_filter_strength_iteration_mmx2(int16_t bS "pxor %%mm2, %%mm2 \n" "pmaxub %%mm0, %%mm1 \n" "punpcklbw %%mm2, %%mm1 \n" - "movq %%mm1, %0 \n" - :"=m"(*bS[dir][edge]) - ::"memory" + "movq %%mm1, %a1(%0,%2) \n" + ::"r"(bS), + "i"(32*dir), + "r"(b_idx) + :"memory" ); } } @@ -194,8 +200,10 @@ static void h264_loop_filter_strength_mmx2( int16_t bS[2][4][4], uint8_t nnz[40] // could do a special case for dir==0 && edges==1, but it only reduces the // average filter time by 1.2% + step <<= 3; + edges <<= 3; h264_loop_filter_strength_iteration_mmx2(bS, nnz, ref, mv, bidir, edges, step, mask_mv1, 1, -8, 0); - h264_loop_filter_strength_iteration_mmx2(bS, nnz, ref, mv, bidir, 4, 1, mask_mv0, 0, -1, -1); + h264_loop_filter_strength_iteration_mmx2(bS, nnz, ref, mv, bidir, 32, 8, mask_mv0, 0, -1, -1); __asm__ volatile( "movq (%0), %%mm0 \n\t" -- 2.11.0