libhevc-mirror/tests/decoder/DecTests.cpp
Harish Mahendrakar 2887504d35
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
Add u4_enable_hbd to control 10-bit decoding support
- Add u4_enable_hbd member to ihevcd_cxa_create_ip_t and codec_t.
- Return error in ihevcd_parse_sps if u4_enable_hbd is 0 and bit_depth_luma_minus8 or bit_depth_chroma_minus8 are non-zero.
- Initialize u4_enable_hbd to 1 by default in main.c, DecHelper/DecTests, and hevc_dec_fuzzer.cpp.
- Add --enable_hbd command line option in main.c.
- Add test in DecTests.cpp to ensure decoder returns an error when decoding 10b clip with u4_enable_hbd set to 0.
2026-09-29 08:29:55 +05:30

121 lines
4.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 <gtest/gtest.h>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <memory>
#include <string>
#include "DecHelper.h"
#include "TestCommon.h"
namespace libhevc {
namespace test {
struct DecodeStreamConfig {
std::string inputFile;
Format format;
std::string refMd5File;
};
void PrintTo(const DecodeStreamConfig& config, ::std::ostream* os) {
*os << config.inputFile;
}
// Helper to resolve absolute file path for test assets
static std::string getFullPath(const std::string& inputFile) {
if (const char* envPath = std::getenv("HEVC_TEST_DIR")) {
return std::string(envPath) + "/" + inputFile;
}
return inputFile;
}
class DecTestFixture
: public ::testing::TestWithParam<std::tuple<DecodeStreamConfig, size_t>> {
protected:
DecTestFixture() = default;
~DecTestFixture() override = default;
};
TEST_P(DecTestFixture, DecodeVerify) {
auto [config, cores] = GetParam();
std::string inputPath = getFullPath(config.inputFile);
std::string refMd5Path = getFullPath(config.refMd5File);
auto builder = DecHelper::Builder()
.setInputFilePath(inputPath)
.setRefMd5Path(refMd5Path)
.setFormat(config.format)
.setCores(cores);
std::unique_ptr<DecHelper> helper = builder.build();
ASSERT_NE(helper, nullptr)
<< "Failed to build DecHelper for input: " << inputPath;
EXPECT_TRUE(helper->decodeFile())
<< "Decoding failed for input: " << inputPath;
}
TEST(DecTest, Decode10bDisabledHbdError) {
const std::vector<std::pair<std::string, Format>> k10bStreams = {
{"bbb_10b_176x144_yuv400.hevc", Format::yuv400p},
{"bbb_10b_176x144_yuv420.hevc", Format::yuv420p},
{"bbb_10b_176x144_yuv422.hevc", Format::yuv422p},
{"bbb_10b_176x144_yuv444.hevc", Format::yuv444p},
};
for (const auto& [inputFile, format] : k10bStreams) {
std::string inputPath = getFullPath(inputFile);
auto builder = DecHelper::Builder()
.setInputFilePath(inputPath)
.setFormat(format)
.setEnableHbd(false);
std::unique_ptr<DecHelper> helper = builder.build();
ASSERT_NE(helper, nullptr)
<< "Failed to build DecHelper for input: " << inputPath;
EXPECT_FALSE(helper->decodeFile())
<< "Decoder should return an error when decoding 10-bit clip with "
"u4_enable_hbd set to 0 for: "
<< inputPath;
}
}
static const std::vector<DecodeStreamConfig> kDecodeStreams = {
{"bbb_176x144_yuv400.hevc", Format::yuv400p, "bbb_176x144_yuv400_md5.txt"},
{"bbb_176x144_yuv420.hevc", Format::yuv420p, "bbb_176x144_yuv420_md5.txt"},
{"bbb_176x144_yuv422.hevc", Format::yuv422p, "bbb_176x144_yuv422_md5.txt"},
{"bbb_176x144_yuv444.hevc", Format::yuv444p, "bbb_176x144_yuv444_md5.txt"},
{"bbb_10b_176x144_yuv400.hevc", Format::yuv400p,
"bbb_10b_176x144_yuv400_md5.txt"},
{"bbb_10b_176x144_yuv420.hevc", Format::yuv420p,
"bbb_10b_176x144_yuv420_md5.txt"},
{"bbb_10b_176x144_yuv422.hevc", Format::yuv422p,
"bbb_10b_176x144_yuv422_md5.txt"},
{"bbb_10b_176x144_yuv444.hevc", Format::yuv444p,
"bbb_10b_176x144_yuv444_md5.txt"},
};
INSTANTIATE_TEST_SUITE_P(DecoderRegression, DecTestFixture,
::testing::Combine(::testing::ValuesIn(kDecodeStreams),
::testing::Values(1, 2, 3, 4)));
} // namespace test
} // namespace libhevc