~4% improvement with a very rudimentary speed test
Unified · Split
| @@ -13,9 +13,10 @@ · 12 unmodified lines | ||
| 13 | 13 | |
| 14 | 14 | #include "third_party/googletest/src/include/gtest/gtest.h" |
| 15 | 15 | |
| 16 | −#include "./vpx_config.h" | |
| 17 | 16 | #include "./vp8_rtcd.h" |
| 17 | +#include "./vpx_config.h" | |
| 18 | 18 | #include "test/acm_random.h" |
| 19 | +#include "test/bench.h" | |
| 19 | 20 | #include "test/clear_system_state.h" |
| 20 | 21 | #include "test/register_state_check.h" |
| 21 | 22 | #include "test/util.h" |
| @@ -117,7 +118,8 @@ class QuantizeTestBase { · 95 unmodified lines | ||
| 117 | 118 | }; |
| 118 | 119 | |
| 119 | 120 | class QuantizeTest : public QuantizeTestBase, |
| 120 | − public ::testing::TestWithParam<VP8QuantizeParam> { | |
| 121 | + public ::testing::TestWithParam<VP8QuantizeParam>, | |
| 122 | + public AbstractBench { | |
| 121 | 123 | protected: |
| 122 | 124 | virtual void SetUp() { |
| 123 | 125 | SetupCompressor(); |
| @@ -125,6 +127,10 @@ class QuantizeTest : public QuantizeTestBase, · 1 unmodified line | ||
| 125 | 127 | c_quant_ = GET_PARAM(1); |
| 126 | 128 | } |
| 127 | 129 | |
| 130 | + virtual void Run() { | |
| 131 | + asm_quant_(&vp8_comp_->mb.block[0], ¯oblockd_dst_->block[0]); | |
| 132 | + } | |
| 133 | + | |
| 128 | 134 | void RunComparison() { |
| 129 | 135 | for (int i = 0; i < kNumBlocks; ++i) { |
| 130 | 136 | ASM_REGISTER_STATE_CHECK( |
| @@ -167,6 +173,13 @@ TEST_P(QuantizeTest, TestMultipleQ) { · 36 unmodified lines | ||
| 167 | 173 | } |
| 168 | 174 | } |
| 169 | 175 | |
| 176 | +TEST_P(QuantizeTest, DISABLED_Speed) { | |
| 177 | + FillCoeffRandom(); | |
| 178 | + | |
| 179 | + RunNTimes(10000000); | |
| 180 | + PrintMedian("vp8 quantize"); | |
| 181 | +} | |
| 182 | + | |
| 170 | 183 | #if HAVE_SSE2 |
| 171 | 184 | INSTANTIATE_TEST_CASE_P( |
| 172 | 185 | SSE2, QuantizeTest, |
| @@ -11,8 +11,8 @@ · 10 unmodified lines | ||
| 11 | 11 | #include <smmintrin.h> /* SSE4.1 */ |
| 12 | 12 | |
| 13 | 13 | #include "./vp8_rtcd.h" |
| 14 | −#include "vp8/encoder/block.h" | |
| 15 | 14 | #include "vp8/common/entropy.h" /* vp8_default_inv_zig_zag */ |
| 15 | +#include "vp8/encoder/block.h" | |
| 16 | 16 | |
| 17 | 17 | #define SELECT_EOB(i, z, x, y, q) \ |
| 18 | 18 | do { \ |
| @@ -31,8 +31,7 @@ void vp8_regular_quantize_b_sse4_1(BLOCK *b, BLOCKD *d) { · 12 unmodified lines | ||
| 31 | 31 | char eob = 0; |
| 32 | 32 | short *zbin_boost_ptr = b->zrun_zbin_boost; |
| 33 | 33 | |
| 34 | − __m128i sz0, x0, sz1, x1, y0, y1, x_minus_zbin0, x_minus_zbin1, dqcoeff0, | |
| 35 | − dqcoeff1; | |
| 34 | + __m128i x0, x1, y0, y1, x_minus_zbin0, x_minus_zbin1, dqcoeff0, dqcoeff1; | |
| 36 | 35 | __m128i quant_shift0 = _mm_load_si128((__m128i *)(b->quant_shift)); |
| 37 | 36 | __m128i quant_shift1 = _mm_load_si128((__m128i *)(b->quant_shift + 8)); |
| 38 | 37 | __m128i z0 = _mm_load_si128((__m128i *)(b->coeff)); |
| @@ -53,15 +52,9 @@ void vp8_regular_quantize_b_sse4_1(BLOCK *b, BLOCKD *d) { · 14 unmodified lines | ||
| 53 | 52 | zbin_extra = _mm_shufflelo_epi16(zbin_extra, 0); |
| 54 | 53 | zbin_extra = _mm_unpacklo_epi16(zbin_extra, zbin_extra); |
| 55 | 54 | |
| 56 | − /* Sign of z: z >> 15 */ | |
| 57 | − sz0 = _mm_srai_epi16(z0, 15); | |
| 58 | − sz1 = _mm_srai_epi16(z1, 15); | |
| 59 | − | |
| 60 | − /* x = abs(z): (z ^ sz) - sz */ | |
| 61 | − x0 = _mm_xor_si128(z0, sz0); | |
| 62 | − x1 = _mm_xor_si128(z1, sz1); | |
| 63 | − x0 = _mm_sub_epi16(x0, sz0); | |
| 64 | − x1 = _mm_sub_epi16(x1, sz1); | |
| 55 | + /* x = abs(z) */ | |
| 56 | + x0 = _mm_abs_epi16(z0); | |
| 57 | + x1 = _mm_abs_epi16(z1); | |
| 65 | 58 | |
| 66 | 59 | /* zbin[] + zbin_extra */ |
| 67 | 60 | zbin0 = _mm_add_epi16(zbin0, zbin_extra); |
| @@ -89,11 +82,9 @@ void vp8_regular_quantize_b_sse4_1(BLOCK *b, BLOCKD *d) { · 21 unmodified lines | ||
| 89 | 82 | y0 = _mm_mulhi_epi16(y0, quant_shift0); |
| 90 | 83 | y1 = _mm_mulhi_epi16(y1, quant_shift1); |
| 91 | 84 | |
| 92 | − /* Return the sign: (y ^ sz) - sz */ | |
| 93 | − y0 = _mm_xor_si128(y0, sz0); | |
| 94 | − y1 = _mm_xor_si128(y1, sz1); | |
| 95 | − y0 = _mm_sub_epi16(y0, sz0); | |
| 96 | − y1 = _mm_sub_epi16(y1, sz1); | |
| 85 | + /* Restore the sign. */ | |
| 86 | + y0 = _mm_sign_epi16(y0, z0); | |
| 87 | + y1 = _mm_sign_epi16(y1, z1); | |
| 97 | 88 | |
| 98 | 89 | /* The loop gets unrolled anyway. Avoid the vp8_default_zig_zag1d lookup. */ |
| 99 | 90 | SELECT_EOB(1, 0, x_minus_zbin0, y0, qcoeff0); |