Libav
|
00001 00024 #include "libavutil/x86_cpu.h" 00025 #include "libavcodec/dsputil.h" 00026 #include "dsputil_mmx.h" 00027 #include "vp6dsp_mmx.h" 00028 00029 00030 #define DIAG4_MMX(in1,in2,in3,in4) \ 00031 "movq "#in1"(%0), %%mm0 \n\t" \ 00032 "movq "#in2"(%0), %%mm1 \n\t" \ 00033 "movq %%mm0, %%mm3 \n\t" \ 00034 "movq %%mm1, %%mm4 \n\t" \ 00035 "punpcklbw %%mm7, %%mm0 \n\t" \ 00036 "punpcklbw %%mm7, %%mm1 \n\t" \ 00037 "punpckhbw %%mm7, %%mm3 \n\t" \ 00038 "punpckhbw %%mm7, %%mm4 \n\t" \ 00039 "pmullw 0(%2), %%mm0 \n\t" /* src[x-8 ] * biweight [0] */ \ 00040 "pmullw 8(%2), %%mm1 \n\t" /* src[x ] * biweight [1] */ \ 00041 "pmullw 0(%2), %%mm3 \n\t" /* src[x-8 ] * biweight [0] */ \ 00042 "pmullw 8(%2), %%mm4 \n\t" /* src[x ] * biweight [1] */ \ 00043 "paddw %%mm1, %%mm0 \n\t" \ 00044 "paddw %%mm4, %%mm3 \n\t" \ 00045 "movq "#in3"(%0), %%mm1 \n\t" \ 00046 "movq "#in4"(%0), %%mm2 \n\t" \ 00047 "movq %%mm1, %%mm4 \n\t" \ 00048 "movq %%mm2, %%mm5 \n\t" \ 00049 "punpcklbw %%mm7, %%mm1 \n\t" \ 00050 "punpcklbw %%mm7, %%mm2 \n\t" \ 00051 "punpckhbw %%mm7, %%mm4 \n\t" \ 00052 "punpckhbw %%mm7, %%mm5 \n\t" \ 00053 "pmullw 16(%2), %%mm1 \n\t" /* src[x+8 ] * biweight [2] */ \ 00054 "pmullw 24(%2), %%mm2 \n\t" /* src[x+16] * biweight [3] */ \ 00055 "pmullw 16(%2), %%mm4 \n\t" /* src[x+8 ] * biweight [2] */ \ 00056 "pmullw 24(%2), %%mm5 \n\t" /* src[x+16] * biweight [3] */ \ 00057 "paddw %%mm2, %%mm1 \n\t" \ 00058 "paddw %%mm5, %%mm4 \n\t" \ 00059 "paddsw %%mm1, %%mm0 \n\t" \ 00060 "paddsw %%mm4, %%mm3 \n\t" \ 00061 "paddsw %%mm6, %%mm0 \n\t" /* Add 64 */ \ 00062 "paddsw %%mm6, %%mm3 \n\t" /* Add 64 */ \ 00063 "psraw $7, %%mm0 \n\t" \ 00064 "psraw $7, %%mm3 \n\t" \ 00065 "packuswb %%mm3, %%mm0 \n\t" \ 00066 "movq %%mm0, (%1) \n\t" 00067 00068 void ff_vp6_filter_diag4_mmx(uint8_t *dst, uint8_t *src, int stride, 00069 const int16_t *h_weights, const int16_t *v_weights) 00070 { 00071 uint8_t tmp[8*11], *t = tmp; 00072 int16_t weights[4*4]; 00073 int i; 00074 src -= stride; 00075 00076 for (i=0; i<4*4; i++) 00077 weights[i] = h_weights[i>>2]; 00078 00079 __asm__ volatile( 00080 "pxor %%mm7, %%mm7 \n\t" 00081 "movq "MANGLE(ff_pw_64)", %%mm6 \n\t" 00082 "1: \n\t" 00083 DIAG4_MMX(-1,0,1,2) 00084 "add $8, %1 \n\t" 00085 "add %3, %0 \n\t" 00086 "decl %4 \n\t" 00087 "jnz 1b \n\t" 00088 : "+r"(src), "+r"(t) 00089 : "r"(weights), "r"((x86_reg)stride), "r"(11) 00090 : "memory"); 00091 00092 t = tmp + 8; 00093 for (i=0; i<4*4; i++) 00094 weights[i] = v_weights[i>>2]; 00095 00096 __asm__ volatile( 00097 "pxor %%mm7, %%mm7 \n\t" 00098 "movq "MANGLE(ff_pw_64)", %%mm6 \n\t" 00099 "1: \n\t" 00100 DIAG4_MMX(-8,0,8,16) 00101 "add $8, %0 \n\t" 00102 "add %3, %1 \n\t" 00103 "decl %4 \n\t" 00104 "jnz 1b \n\t" 00105 : "+r"(t), "+r"(dst) 00106 : "r"(weights), "r"((x86_reg)stride), "r"(8) 00107 : "memory"); 00108 }