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