Forgotten in 7284ab789d5fe271b9d6a1666ab5ea6be8724cca.
Unified · Split
| @@ -43,26 +43,16 @@ DECLARE_ALIGNED(16, static const uint16_t, inv_zigzag_direct16)[64] = { · 42 unmodified lines | ||
| 43 | 43 | #if HAVE_6REGS |
| 44 | 44 | |
| 45 | 45 | #if HAVE_SSE2_INLINE |
| 46 | −#undef COMPILE_TEMPLATE_SSE2 | |
| 47 | −#undef COMPILE_TEMPLATE_SSSE3 | |
| 48 | −#define COMPILE_TEMPLATE_SSE2 1 | |
| 49 | 46 | #define COMPILE_TEMPLATE_SSSE3 0 |
| 50 | −#undef RENAME | |
| 51 | −#undef RENAME_FDCT | |
| 52 | 47 | #define RENAME(a) a ## _sse2 |
| 53 | −#define RENAME_FDCT(a) a ## _sse2 | |
| 54 | 48 | #include "mpegvideoenc_template.c" |
| 55 | 49 | #endif /* HAVE_SSE2_INLINE */ |
| 56 | 50 | |
| 57 | 51 | #if HAVE_SSSE3_INLINE |
| 58 | −#undef COMPILE_TEMPLATE_SSE2 | |
| 59 | 52 | #undef COMPILE_TEMPLATE_SSSE3 |
| 60 | −#define COMPILE_TEMPLATE_SSE2 1 | |
| 61 | 53 | #define COMPILE_TEMPLATE_SSSE3 1 |
| 62 | 54 | #undef RENAME |
| 63 | −#undef RENAME_FDCT | |
| 64 | 55 | #define RENAME(a) a ## _ssse3 |
| 65 | −#define RENAME_FDCT(a) a ## _sse2 | |
| 66 | 56 | #include "mpegvideoenc_template.c" |
| 67 | 57 | #endif /* HAVE_SSSE3_INLINE */ |
| 68 | 58 | |
| @@ -29,49 +29,22 @@ · 28 unmodified lines | ||
| 29 | 29 | #include "libavcodec/mpegvideoenc.h" |
| 30 | 30 | #include "fdct.h" |
| 31 | 31 | |
| 32 | −#undef MMREG_WIDTH | |
| 33 | −#undef MM | |
| 34 | −#undef MOVQ | |
| 35 | 32 | #undef SPREADW |
| 36 | 33 | #undef PMAXW |
| 37 | 34 | #undef PMAX |
| 38 | 35 | #undef SAVE_SIGN |
| 39 | 36 | #undef RESTORE_SIGN |
| 40 | 37 | |
| 41 | −#if COMPILE_TEMPLATE_SSE2 | |
| 42 | −#define MMREG_WIDTH "16" | |
| 43 | −#define MM "%%xmm" | |
| 44 | −#define MOVQ "movdqa" | |
| 45 | 38 | #define SPREADW(a) \ |
| 46 | 39 | "pshuflw $0, "a", "a" \n\t"\ |
| 47 | 40 | "punpcklwd "a", "a" \n\t" |
| 48 | −#define PMAXW(a,b) "pmaxsw "a", "b" \n\t" | |
| 49 | 41 | #define PMAX(a,b) \ |
| 50 | 42 | "movhlps "a", "b" \n\t"\ |
| 51 | − PMAXW(b, a)\ | |
| 43 | + "pmaxsw "b", "a" \n\t"\ | |
| 52 | 44 | "pshuflw $0x0E, "a", "b" \n\t"\ |
| 53 | − PMAXW(b, a)\ | |
| 45 | + "pmaxsw "b", "a" \n\t"\ | |
| 54 | 46 | "pshuflw $0x01, "a", "b" \n\t"\ |
| 55 | − PMAXW(b, a) | |
| 56 | −#else | |
| 57 | −#define MMREG_WIDTH "8" | |
| 58 | −#define MM "%%mm" | |
| 59 | −#define MOVQ "movq" | |
| 60 | −#define SPREADW(a) \ | |
| 61 | − "punpcklwd "a", "a" \n\t"\ | |
| 62 | − "punpcklwd "a", "a" \n\t" | |
| 63 | −#define PMAXW(a,b) \ | |
| 64 | − "psubusw "a", "b" \n\t"\ | |
| 65 | − "paddw "a", "b" \n\t" | |
| 66 | −#define PMAX(a,b) \ | |
| 67 | − "movq "a", "b" \n\t"\ | |
| 68 | − "psrlq $32, "a" \n\t"\ | |
| 69 | − PMAXW(b, a)\ | |
| 70 | − "movq "a", "b" \n\t"\ | |
| 71 | − "psrlq $16, "a" \n\t"\ | |
| 72 | − PMAXW(b, a) | |
| 73 | − | |
| 74 | −#endif | |
| 47 | + "pmaxsw "b", "a" \n\t" | |
| 75 | 48 | |
| 76 | 49 | #if COMPILE_TEMPLATE_SSSE3 |
| 77 | 50 | #define SAVE_SIGN(a,b) \ |
| @@ -100,7 +73,7 @@ static int RENAME(dct_quantize)(MPVEncContext *const s, · 22 unmodified lines | ||
| 100 | 73 | LOCAL_ALIGNED_16(int16_t, temp_block, [64]); |
| 101 | 74 | |
| 102 | 75 | //s->fdct (block); |
| 103 | − RENAME_FDCT(ff_fdct)(block); // cannot be anything else ... | |
| 76 | + ff_fdct_sse2(block); // cannot be anything else ... | |
| 104 | 77 | |
| 105 | 78 | if(s->dct_error_sum) |
| 106 | 79 | s->denoise_dct(s, block); |
| @@ -138,32 +111,32 @@ static int RENAME(dct_quantize)(MPVEncContext *const s, · 31 unmodified lines | ||
| 138 | 111 | |
| 139 | 112 | if ((s->c.out_format == FMT_H263 || s->c.out_format == FMT_H261) && !s->c.mpeg_quant) { |
| 140 | 113 | __asm__ volatile( |
| 141 | − "movd %%"FF_REG_a", "MM"3 \n\t" // last_non_zero_p1 | |
| 142 | − SPREADW(MM"3") | |
| 143 | − "pxor "MM"7, "MM"7 \n\t" // 0 | |
| 144 | − "pxor "MM"4, "MM"4 \n\t" // 0 | |
| 145 | − MOVQ" (%2), "MM"5 \n\t" // qmat[0] | |
| 146 | − "pxor "MM"6, "MM"6 \n\t" | |
| 147 | − "psubw (%3), "MM"6 \n\t" // -bias[0] | |
| 114 | + "movd %%"FF_REG_a", %%xmm3 \n\t" // last_non_zero_p1 | |
| 115 | + SPREADW("%%xmm3") | |
| 116 | + "pxor %%xmm7, %%xmm7 \n\t" // 0 | |
| 117 | + "pxor %%xmm4, %%xmm4 \n\t" // 0 | |
| 118 | + "movdqa (%2), %%xmm5 \n\t" // qmat[0] | |
| 119 | + "pxor %%xmm6, %%xmm6 \n\t" | |
| 120 | + "psubw (%3), %%xmm6 \n\t" // -bias[0] | |
| 148 | 121 | "mov $-128, %%"FF_REG_a" \n\t" |
| 149 | 122 | ".p2align 4 \n\t" |
| 150 | 123 | "1: \n\t" |
| 151 | − MOVQ" (%1, %%"FF_REG_a"), "MM"0 \n\t" // block[i] | |
| 152 | − SAVE_SIGN(MM"1", MM"0") // ABS(block[i]) | |
| 153 | − "psubusw "MM"6, "MM"0 \n\t" // ABS(block[i]) + bias[0] | |
| 154 | − "pmulhw "MM"5, "MM"0 \n\t" // (ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16 | |
| 155 | − "por "MM"0, "MM"4 \n\t" | |
| 156 | − RESTORE_SIGN(MM"1", MM"0") // out=((ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16)*sign(block[i]) | |
| 157 | − MOVQ" "MM"0, (%5, %%"FF_REG_a") \n\t" | |
| 158 | − "pcmpeqw "MM"7, "MM"0 \n\t" // out==0 ? 0xFF : 0x00 | |
| 159 | − MOVQ" (%4, %%"FF_REG_a"), "MM"1 \n\t" | |
| 160 | − MOVQ" "MM"7, (%1, %%"FF_REG_a") \n\t" // 0 | |
| 161 | − "pandn "MM"1, "MM"0 \n\t" | |
| 162 | − PMAXW(MM"0", MM"3") | |
| 163 | − "add $"MMREG_WIDTH", %%"FF_REG_a" \n\t" | |
| 124 | + "movdqa (%1, %%"FF_REG_a"), %%xmm0 \n\t" // block[i] | |
| 125 | + SAVE_SIGN("%%xmm1", "%%xmm0") // ABS(block[i]) | |
| 126 | + "psubusw %%xmm6, %%xmm0 \n\t" // ABS(block[i]) + bias[0] | |
| 127 | + "pmulhw %%xmm5, %%xmm0 \n\t" // (ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16 | |
| 128 | + "por %%xmm0, %%xmm4 \n\t" | |
| 129 | + RESTORE_SIGN("%%xmm1", "%%xmm0") // out=((ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16)*sign(block[i]) | |
| 130 | + "movdqa %%xmm0, (%5, %%"FF_REG_a") \n\t" | |
| 131 | + "pcmpeqw %%xmm7, %%xmm0 \n\t" // out==0 ? 0xFF : 0x00 | |
| 132 | + "movdqa (%4, %%"FF_REG_a"), %%xmm1 \n\t" | |
| 133 | + "movdqa %%xmm7, (%1, %%"FF_REG_a") \n\t" // 0 | |
| 134 | + "pandn %%xmm1, %%xmm0 \n\t" | |
| 135 | + "pmaxsw %%xmm0, %%xmm3 \n\t" | |
| 136 | + "add $16, %%"FF_REG_a" \n\t" | |
| 164 | 137 | " js 1b \n\t" |
| 165 | − PMAX(MM"3", MM"0") | |
| 166 | − "movd "MM"3, %%"FF_REG_a" \n\t" | |
| 138 | + PMAX("%%xmm3", "%%xmm0") | |
| 139 | + "movd %%xmm3, %%"FF_REG_a" \n\t" | |
| 167 | 140 | "movzbl %%al, %%eax \n\t" // last_non_zero_p1 |
| 168 | 141 | : "+a" (last_non_zero_p1) |
| 169 | 142 | : "r" (block+64), "r" (qmat), "r" (bias), |
| @@ -173,31 +146,31 @@ static int RENAME(dct_quantize)(MPVEncContext *const s, · 3 unmodified lines | ||
| 173 | 146 | ); |
| 174 | 147 | }else{ // FMT_H263 |
| 175 | 148 | __asm__ volatile( |
| 176 | − "movd %%"FF_REG_a", "MM"3 \n\t" // last_non_zero_p1 | |
| 177 | − SPREADW(MM"3") | |
| 178 | − "pxor "MM"7, "MM"7 \n\t" // 0 | |
| 179 | − "pxor "MM"4, "MM"4 \n\t" // 0 | |
| 149 | + "movd %%"FF_REG_a", %%xmm3 \n\t" // last_non_zero_p1 | |
| 150 | + SPREADW("%%xmm3") | |
| 151 | + "pxor %%xmm7, %%xmm7 \n\t" // 0 | |
| 152 | + "pxor %%xmm4, %%xmm4 \n\t" // 0 | |
| 180 | 153 | "mov $-128, %%"FF_REG_a" \n\t" |
| 181 | 154 | ".p2align 4 \n\t" |
| 182 | 155 | "1: \n\t" |
| 183 | − MOVQ" (%1, %%"FF_REG_a"), "MM"0 \n\t" // block[i] | |
| 184 | − SAVE_SIGN(MM"1", MM"0") // ABS(block[i]) | |
| 185 | − MOVQ" (%3, %%"FF_REG_a"), "MM"6 \n\t" // bias[0] | |
| 186 | − "paddusw "MM"6, "MM"0 \n\t" // ABS(block[i]) + bias[0] | |
| 187 | − MOVQ" (%2, %%"FF_REG_a"), "MM"5 \n\t" // qmat[i] | |
| 188 | − "pmulhw "MM"5, "MM"0 \n\t" // (ABS(block[i])*qmat[0] + bias[0]*qmat[0])>>16 | |
| 189 | − "por "MM"0, "MM"4 \n\t" | |
| 190 | − RESTORE_SIGN(MM"1", MM"0") // out=((ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16)*sign(block[i]) | |
| 191 | − MOVQ" "MM"0, (%5, %%"FF_REG_a") \n\t" | |
| 192 | − "pcmpeqw "MM"7, "MM"0 \n\t" // out==0 ? 0xFF : 0x00 | |
| 193 | − MOVQ" (%4, %%"FF_REG_a"), "MM"1 \n\t" | |
| 194 | − MOVQ" "MM"7, (%1, %%"FF_REG_a") \n\t" // 0 | |
| 195 | − "pandn "MM"1, "MM"0 \n\t" | |
| 196 | − PMAXW(MM"0", MM"3") | |
| 197 | − "add $"MMREG_WIDTH", %%"FF_REG_a" \n\t" | |
| 156 | + "movdqa (%1, %%"FF_REG_a"), %%xmm0 \n\t" // block[i] | |
| 157 | + SAVE_SIGN("%%xmm1", "%%xmm0") // ABS(block[i]) | |
| 158 | + "movdqa (%3, %%"FF_REG_a"), %%xmm6 \n\t" // bias[0] | |
| 159 | + "paddusw %%xmm6, %%xmm0 \n\t" // ABS(block[i]) + bias[0] | |
| 160 | + "movdqa (%2, %%"FF_REG_a"), %%xmm5 \n\t" // qmat[i] | |
| 161 | + "pmulhw %%xmm5, %%xmm0 \n\t" // (ABS(block[i])*qmat[0] + bias[0]*qmat[0])>>16 | |
| 162 | + "por %%xmm0, %%xmm4 \n\t" | |
| 163 | + RESTORE_SIGN("%%xmm1", "%%xmm0") // out=((ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16)*sign(block[i]) | |
| 164 | + "movdqa %%xmm0, (%5, %%"FF_REG_a") \n\t" | |
| 165 | + "pcmpeqw %%xmm7, %%xmm0 \n\t" // out==0 ? 0xFF : 0x00 | |
| 166 | + "movdqa (%4, %%"FF_REG_a"), %%xmm1 \n\t" | |
| 167 | + "movdqa %%xmm7, (%1, %%"FF_REG_a") \n\t" // 0 | |
| 168 | + "pandn %%xmm1, %%xmm0 \n\t" | |
| 169 | + "pmaxsw %%xmm0, %%xmm3 \n\t" | |
| 170 | + "add $16, %%"FF_REG_a" \n\t" | |
| 198 | 171 | " js 1b \n\t" |
| 199 | − PMAX(MM"3", MM"0") | |
| 200 | − "movd "MM"3, %%"FF_REG_a" \n\t" | |
| 172 | + PMAX("%%xmm3", "%%xmm0") | |
| 173 | + "movd %%xmm3, %%"FF_REG_a" \n\t" | |
| 201 | 174 | "movzbl %%al, %%eax \n\t" // last_non_zero_p1 |
| 202 | 175 | : "+a" (last_non_zero_p1) |
| 203 | 176 | : "r" (block+64), "r" (qmat+64), "r" (bias+64), |
| @@ -207,14 +180,12 @@ static int RENAME(dct_quantize)(MPVEncContext *const s, · 3 unmodified lines | ||
| 207 | 180 | ); |
| 208 | 181 | } |
| 209 | 182 | __asm__ volatile( |
| 210 | − "movd %1, "MM"1 \n\t" // max_qcoeff | |
| 211 | − SPREADW(MM"1") | |
| 212 | − "psubusw "MM"1, "MM"4 \n\t" | |
| 213 | − "packuswb "MM"4, "MM"4 \n\t" | |
| 214 | −#if COMPILE_TEMPLATE_SSE2 | |
| 215 | − "packsswb "MM"4, "MM"4 \n\t" | |
| 216 | −#endif | |
| 217 | − "movd "MM"4, %0 \n\t" // *overflow | |
| 183 | + "movd %1, %%xmm1 \n\t" // max_qcoeff | |
| 184 | + SPREADW("%%xmm1") | |
| 185 | + "psubusw %%xmm1, %%xmm4 \n\t" | |
| 186 | + "packuswb %%xmm4, %%xmm4 \n\t" | |
| 187 | + "packsswb %%xmm4, %%xmm4 \n\t" | |
| 188 | + "movd %%xmm4, %0 \n\t" // *overflow | |
| 218 | 189 | : "=g" (*overflow) |
| 219 | 190 | : "g" (s->max_qcoeff) |
| 220 | 191 | ); |