]> granicus.if.org Git - libvpx/blobdiff - test/quantize_test.cc
Merge "endian_inl.h: fix mips32 android build"
[libvpx] / test / quantize_test.cc
index e3fd1c84376f6a933040feb1320fe1a3378698a6..69da8994ca1d3b876195eac13fc0fac74bf5f348 100644 (file)
 #include <string.h>
 
 #include "third_party/googletest/src/include/gtest/gtest.h"
+
+#include "./vpx_config.h"
+#include "./vp8_rtcd.h"
 #include "test/acm_random.h"
 #include "test/clear_system_state.h"
 #include "test/register_state_check.h"
 #include "test/util.h"
-
-#include "./vpx_config.h"
-#include "./vp8_rtcd.h"
 #include "vp8/common/blockd.h"
 #include "vp8/common/onyx.h"
 #include "vp8/encoder/block.h"
@@ -32,10 +32,8 @@ const int kNumBlocks = 25;
 const int kNumBlockEntries = 16;
 
 typedef void (*VP8Quantize)(BLOCK *b, BLOCKD *d);
-typedef void (*VP8QuantizePair)(BLOCK *b0, BLOCK *b1, BLOCKD *d0, BLOCKD *d1);
 
 typedef std::tr1::tuple<VP8Quantize, VP8Quantize> VP8QuantizeParam;
-typedef std::tr1::tuple<VP8QuantizePair, VP8QuantizePair> VP8QuantizePairParam;
 
 using libvpx_test::ACMRandom;
 using std::tr1::make_tuple;
@@ -57,10 +55,10 @@ class QuantizeTestBase {
     rnd_.Reset(ACMRandom::DeterministicSeed());
 
     // The full configuration is necessary to generate the quantization tables.
-    VP8_CONFIG *const vp8_config =
-        reinterpret_cast<VP8_CONFIG *>(vpx_calloc(sizeof(*vp8_config), 1));
+    VP8_CONFIG vp8_config;
+    memset(&vp8_config, 0, sizeof(vp8_config));
 
-    vp8_comp_ = vp8_create_compressor(vp8_config);
+    vp8_comp_ = vp8_create_compressor(&vp8_config);
 
     // Set the tables based on a quantizer of 0.
     vp8_set_quantizer(vp8_comp_, 0);
@@ -69,11 +67,9 @@ class QuantizeTestBase {
     vp8cx_frame_init_quantizer(vp8_comp_);
 
     // Copy macroblockd from the reference to get pre-set-up dequant values.
-    macroblockd_dst_ =
-        reinterpret_cast<MACROBLOCKD *>(
-            vpx_calloc(sizeof(*macroblockd_dst_), 1));
-    vpx_memcpy(macroblockd_dst_, &vp8_comp_->mb.e_mbd,
-               sizeof(*macroblockd_dst_));
+    macroblockd_dst_ = reinterpret_cast<MACROBLOCKD *>(
+        vpx_memalign(32, sizeof(*macroblockd_dst_)));
+    memcpy(macroblockd_dst_, &vp8_comp_->mb.e_mbd, sizeof(*macroblockd_dst_));
     // Fix block pointers - currently they point to the blocks in the reference
     // structure.
     vp8_setup_block_dptrs(macroblockd_dst_);
@@ -82,8 +78,7 @@ class QuantizeTestBase {
   void UpdateQuantizer(int q) {
     vp8_set_quantizer(vp8_comp_, q);
 
-    vpx_memcpy(macroblockd_dst_, &vp8_comp_->mb.e_mbd,
-               sizeof(*macroblockd_dst_));
+    memcpy(macroblockd_dst_, &vp8_comp_->mb.e_mbd, sizeof(*macroblockd_dst_));
     vp8_setup_block_dptrs(macroblockd_dst_);
   }
 
@@ -145,63 +140,25 @@ class QuantizeTest : public QuantizeTestBase,
   VP8Quantize c_quant_;
 };
 
-class QuantizeTestPair : public QuantizeTestBase,
-                         public ::testing::TestWithParam<VP8QuantizePairParam> {
- protected:
-  virtual void SetUp() {
-    SetupCompressor();
-    asm_quant_pair_ = GET_PARAM(0);
-    c_quant_pair_ = GET_PARAM(1);
-  }
-
-  void RunComparison() {
-    // Skip the last, unpaired, block.
-    for (int i = 0; i < kNumBlocks - 1; i += 2) {
-      ASM_REGISTER_STATE_CHECK(c_quant_pair_(
-          &vp8_comp_->mb.block[i], &vp8_comp_->mb.block[i + 1],
-          &vp8_comp_->mb.e_mbd.block[i], &vp8_comp_->mb.e_mbd.block[i + 1]));
-      ASM_REGISTER_STATE_CHECK(asm_quant_pair_(
-          &vp8_comp_->mb.block[i], &vp8_comp_->mb.block[i + 1],
-          &macroblockd_dst_->block[i], &macroblockd_dst_->block[i + 1]));
-    }
-
-    CheckOutput();
-  }
-
- private:
-  VP8QuantizePair asm_quant_pair_;
-  VP8QuantizePair c_quant_pair_;
-};
-
 TEST_P(QuantizeTest, TestZeroInput) {
   FillCoeffConstant(0);
   RunComparison();
 }
 
-TEST_P(QuantizeTest, TestRandomInput) {
-  FillCoeffRandom();
-  RunComparison();
-}
-
-TEST_P(QuantizeTest, TestMultipleQ) {
-  for (int q = 0; q < QINDEX_RANGE; ++q) {
-    UpdateQuantizer(q);
-    FillCoeffRandom();
-    RunComparison();
-  }
-}
-
-TEST_P(QuantizeTestPair, TestZeroInput) {
+TEST_P(QuantizeTest, TestLargeNegativeInput) {
   FillCoeffConstant(0);
+  // Generate a qcoeff which contains 512/-512 (0x0100/0xFE00) to catch issues
+  // like BUG=883 where the constant being compared was incorrectly initialized.
+  vp8_comp_->mb.coeff[0] = -8191;
   RunComparison();
 }
 
-TEST_P(QuantizeTestPair, TestRandomInput) {
+TEST_P(QuantizeTest, TestRandomInput) {
   FillCoeffRandom();
   RunComparison();
 }
 
-TEST_P(QuantizeTestPair, TestMultipleQ) {
+TEST_P(QuantizeTest, TestMultipleQ) {
   for (int q = 0; q < QINDEX_RANGE; ++q) {
     UpdateQuantizer(q);
     FillCoeffRandom();
@@ -213,36 +170,34 @@ TEST_P(QuantizeTestPair, TestMultipleQ) {
 INSTANTIATE_TEST_CASE_P(
     SSE2, QuantizeTest,
     ::testing::Values(
-        make_tuple(vp8_fast_quantize_b_sse2, vp8_fast_quantize_b_c),
-        make_tuple(vp8_regular_quantize_b_sse2, vp8_regular_quantize_b_c)));
+        make_tuple(&vp8_fast_quantize_b_sse2, &vp8_fast_quantize_b_c),
+        make_tuple(&vp8_regular_quantize_b_sse2, &vp8_regular_quantize_b_c)));
 #endif  // HAVE_SSE2
 
 #if HAVE_SSSE3
 INSTANTIATE_TEST_CASE_P(SSSE3, QuantizeTest,
-                        ::testing::Values(make_tuple(vp8_fast_quantize_b_ssse3,
-                                                     vp8_fast_quantize_b_c)));
+                        ::testing::Values(make_tuple(&vp8_fast_quantize_b_ssse3,
+                                                     &vp8_fast_quantize_b_c)));
 #endif  // HAVE_SSSE3
 
 #if HAVE_SSE4_1
-INSTANTIATE_TEST_CASE_P(SSE4_1, QuantizeTest, ::testing::Values(make_tuple(
-                                                  vp8_regular_quantize_b_sse4_1,
-                                                  vp8_regular_quantize_b_c)));
+INSTANTIATE_TEST_CASE_P(
+    SSE4_1, QuantizeTest,
+    ::testing::Values(make_tuple(&vp8_regular_quantize_b_sse4_1,
+                                 &vp8_regular_quantize_b_c)));
 #endif  // HAVE_SSE4_1
 
-#if HAVE_MEDIA
-INSTANTIATE_TEST_CASE_P(MEDIA, QuantizeTest,
-                        ::testing::Values(make_tuple(vp8_fast_quantize_b_armv6,
-                                                     vp8_fast_quantize_b_c)));
-#endif  // HAVE_MEDIA
-
-#if HAVE_NEON_ASM
+#if HAVE_NEON
 INSTANTIATE_TEST_CASE_P(NEON, QuantizeTest,
-                        ::testing::Values(make_tuple(vp8_fast_quantize_b_neon,
-                                                     vp8_fast_quantize_b_c)));
+                        ::testing::Values(make_tuple(&vp8_fast_quantize_b_neon,
+                                                     &vp8_fast_quantize_b_c)));
+#endif  // HAVE_NEON
 
+#if HAVE_MSA
 INSTANTIATE_TEST_CASE_P(
-    NEON, QuantizeTestPair,
-    ::testing::Values(make_tuple(vp8_fast_quantize_b_pair_neon,
-                                 vp8_fast_quantize_b_pair_c)));
-#endif  // HAVE_NEON_ASM
+    MSA, QuantizeTest,
+    ::testing::Values(
+        make_tuple(&vp8_fast_quantize_b_msa, &vp8_fast_quantize_b_c),
+        make_tuple(&vp8_regular_quantize_b_msa, &vp8_regular_quantize_b_c)));
+#endif  // HAVE_MSA
 }  // namespace