libhevc-mirror/tests/common/TestCommon.cc
Harish Mahendrakar 89da890161
Some checks failed
CMake / build (cmake, aarch64-linux-gnu-gcc, -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch64_toolchain.cmake, aarch64-linux-gnu-g++, ubuntu-latest-cross-aarch64-cmake, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, arm-linux-gnueabihf-gcc, -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch32_toolchain.cmake, arm-linux-gnueabihf-g++, ubuntu-latest-cross-aarch32-cmake, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, , clang++, macos-latest-clang-cmake, macos-latest) (push) Has been cancelled
CMake / build (cmake, clang, , clang++, ubuntu-24.04-arm-clang-cmake, ubuntu-24.04-arm) (push) Has been cancelled
CMake / build (cmake, clang, , clang++, ubuntu-latest-clang-cmake, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, -DSANITIZE=fuzzer-no-link,address, clang++, ubuntu-latest-clang-cmake-asan-fuzzer, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, -G Ninja, clang++, ubuntu-latest-clang-cmake-ninja, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, gcc, , g++, ubuntu-latest-gcc-cmake, ubuntu-latest) (push) Has been cancelled
Added benchmark tests for ihevc modules
2026-09-26 11:04:34 -07:00

117 lines
No EOL
3.2 KiB
C++

/******************************************************************************
*
* Copyright (C) 2026 Ittiam Systems Pvt Ltd, Bangalore
*
* 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 <algorithm>
#include <cstring>
#include <random>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// clang-format off
#include "ihevc_typedefs.h"
#include "ihevc_inter_pred.h"
#include "ihevc_function_selector.h"
#include "iv.h"
#include "TestCommon.h"
// clang-format on
const std::vector<std::pair<int, int>>& getLumaPUBlockSizes() {
static const std::vector<std::pair<int, int>> kPUBlockSizes = {
// clang-format off
{4, 4},
{8, 8}, {8, 4}, {4, 8},
{16, 16}, {16, 12}, {16, 8}, {16, 4}, {12, 16}, {8, 16}, {4, 16},
{32, 32}, {32, 24}, {32, 16}, {32, 8}, {24, 32}, {16, 32}, {8, 32},
{64, 64}, {64, 48}, {64, 32}, {64, 16}, {48, 64}, {32, 64}, {16, 64},
// clang-format on
};
return kPUBlockSizes;
}
const std::vector<std::pair<int, int>>& getChromaPUBlockSizes() {
static const std::vector<std::pair<int, int>> kChromaPUBlockSizes = []() {
std::vector<std::pair<int, int>> ret;
for (const auto& size : getLumaPUBlockSizes()) {
ret.push_back({size.first / 2, size.second / 2});
}
return ret;
}();
return kChromaPUBlockSizes;
}
const std::vector<UWORD8>& getSrc8Buf() {
static const std::vector<UWORD8> g_src8_buf = []() {
std::vector<UWORD8> buf(kMaxSize * kMaxHeight * 4);
FillRandom(buf, static_cast<UWORD8>(0), static_cast<UWORD8>(255), 12345);
return buf;
}();
return g_src8_buf;
}
std::string get_arch_str(IV_ARCH_T arch) {
std::string arch_str;
switch (arch) {
case ARCH_NA:
arch_str = "C";
break;
case ARCH_X86_GENERIC:
arch_str = "GENERIC";
break;
case ARCH_X86_SSSE3:
arch_str = "SSSE3";
break;
case ARCH_X86_SSE42:
arch_str = "SSE42";
break;
case ARCH_X86_AVX2:
arch_str = "AVX2";
break;
case ARCH_ARMV8_GENERIC:
arch_str = "ARMV8";
break;
case ARCH_ARM_A9Q:
arch_str = "A9Q";
break;
default:
arch_str = "UNKNOWN";
break;
}
return arch_str;
}
const std::vector<IV_ARCH_T>& getTstArch() {
static const std::vector<IV_ARCH_T> ga_tst_arch = {
#if defined(__x86_64__) || defined(_M_X64) || defined(__i386) || \
defined(_M_IX86)
ARCH_X86_SSSE3,
ARCH_X86_SSE42,
#ifndef DISABLE_AVX2
ARCH_X86_AVX2,
#endif // DISABLE_AVX2
#elif defined(__aarch64__)
ARCH_ARMV8_GENERIC,
#elif defined(__arm__)
ARCH_ARM_A9Q,
#endif
};
return ga_tst_arch;
}