#include <array>
#include <memory>
#include "gtest/gtest.h"
#include "test/codec_factory.h"
#include "test/video_source.h"
#include "test/util.h"
namespace {
class AV1FrameSizeTests : public ::testing::Test,
public ::libaom_test::EncoderTest { … };
#if CONFIG_SIZE_LIMIT
TEST_F(AV1FrameSizeTests, DISABLED_TestInvalidSizes) { … }
TEST_F(AV1FrameSizeTests, DISABLED_LargeValidSizes) { … }
#endif
TEST_F(AV1FrameSizeTests, OneByOneVideo) { … }
class AV1ResolutionChange
: public testing::TestWithParam<std::tuple<int, aom_rc_mode, int>> { … };
TEST_P(AV1ResolutionChange, InvalidRefSize) { … }
TEST_P(AV1ResolutionChange, RandomInput) { … }
TEST_P(AV1ResolutionChange, InvalidInputSize) { … }
INSTANTIATE_TEST_SUITE_P(…);
#if !CONFIG_REALTIME_ONLY
INSTANTIATE_TEST_SUITE_P(
GoodQuality, AV1ResolutionChange,
::testing::Combine(::testing::Values(AOM_USAGE_GOOD_QUALITY),
::testing::Values(AOM_VBR, AOM_CBR, AOM_CQ, AOM_Q),
::testing::Range(2, 6)));
INSTANTIATE_TEST_SUITE_P(
GoodQualityLarge, AV1ResolutionChange,
::testing::Combine(::testing::Values(AOM_USAGE_GOOD_QUALITY),
::testing::Values(AOM_VBR, AOM_CBR, AOM_CQ, AOM_Q),
::testing::Range(0, 2)));
INSTANTIATE_TEST_SUITE_P(
AllIntra, AV1ResolutionChange,
::testing::Combine(::testing::Values(AOM_USAGE_ALL_INTRA),
::testing::Values(AOM_Q), ::testing::Range(6, 10)));
typedef struct {
unsigned int width;
unsigned int height;
} FrameSizeParam;
const FrameSizeParam FrameSizeTestParams[] = { { 96, 96 }, { 176, 144 } };
class AV1LosslessFrameSizeTests
: public ::libaom_test::CodecTestWith2Params<FrameSizeParam,
::libaom_test::TestMode>,
public ::libaom_test::EncoderTest {
protected:
AV1LosslessFrameSizeTests()
: EncoderTest(GET_PARAM(0)), frame_size_param_(GET_PARAM(1)),
encoding_mode_(GET_PARAM(2)) {}
~AV1LosslessFrameSizeTests() override = default;
void SetUp() override { InitializeConfig(encoding_mode_); }
bool HandleDecodeResult(const aom_codec_err_t res_dec,
libaom_test::Decoder *decoder) override {
EXPECT_EQ(expected_res_, res_dec) << decoder->DecodeError();
return !::testing::Test::HasFailure();
}
void PreEncodeFrameHook(::libaom_test::VideoSource *video,
::libaom_test::Encoder *encoder) override {
if (video->frame() == 0) {
encoder->Control(AOME_SET_CPUUSED, 6);
encoder->Control(AV1E_SET_LOSSLESS, 1);
}
}
const FrameSizeParam frame_size_param_;
const ::libaom_test::TestMode encoding_mode_;
int expected_res_;
};
TEST_P(AV1LosslessFrameSizeTests, LosslessEncode) {
::libaom_test::RandomVideoSource video;
video.SetSize(frame_size_param_.width, frame_size_param_.height);
video.set_limit(10);
expected_res_ = AOM_CODEC_OK;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
}
AV1_INSTANTIATE_TEST_SUITE(AV1LosslessFrameSizeTests,
::testing::ValuesIn(FrameSizeTestParams),
testing::Values(::libaom_test::kAllIntra));
#endif
}