aboutsummaryrefslogtreecommitdiff
path: root/src/dsp/common_dsp_test.cc
blob: 3342ce857c6c27969d12af539d943fa7585849f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2023 The libgav1 Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "absl/strings/match.h"
#include "gtest/gtest.h"
#include "src/dsp/x86/common_avx2_test.h"
#include "src/dsp/x86/common_sse4_test.h"
#include "src/utils/cpu.h"

namespace libgav1 {
namespace dsp {
namespace {

class CommonDspTest : public ::testing::Test {
 protected:
  void SetUp() override {
    const testing::TestInfo* const test_info =
        testing::UnitTest::GetInstance()->current_test_info();
    const char* const test_case = test_info->name();
    if (absl::StartsWith(test_case, "SSE41")) {
      if ((GetCpuInfo() & kSSE4_1) == 0) GTEST_SKIP() << "No SSE4.1 support!";
    } else if (absl::StartsWith(test_case, "AVX2")) {
      if ((GetCpuInfo() & kAVX2) == 0) GTEST_SKIP() << "No AVX2 support!";
    } else {
      FAIL() << "Unrecognized architecture prefix in test case name: "
             << test_case;
    }
  }
};

GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(CommonDspTest);

#if LIBGAV1_ENABLE_AVX2
TEST_F(CommonDspTest, AVX2RightShiftWithRoundingS16) {
  AVX2RightShiftWithRoundingS16Test();
}
#endif  // LIBGAV1_ENABLE_AVX2

#if LIBGAV1_ENABLE_SSE4_1
TEST_F(CommonDspTest, SSE41RightShiftWithRoundingS16) {
  SSE41RightShiftWithRoundingS16Test();
}
#endif  // LIBGAV1_ENABLE_SSE41

}  // namespace
}  // namespace dsp
}  // namespace libgav1