Add AV1LosslessFrameSizeTests.LosslessEncode unit test
This patch adds an unit-test to validate the allocated size of
bitstream buffer, by feeding pseudo random input to the
encoder in ALLINTRA lossless mode.
As a part of the CL, added kAllIntra to Testmode enum and also
removed an unused macro ONE_BY_ONE_VIDEO_NAME in
frame_size_tests.cc
BUG=aomedia:2938,aomedia:2959
Change-Id: I530166af5ea7a5364bd635698e9ce4f81879aa76
diff --git a/test/encode_test_driver.cc b/test/encode_test_driver.cc
index 982f7d9..058e08e 100644
--- a/test/encode_test_driver.cc
+++ b/test/encode_test_driver.cc
@@ -89,6 +89,7 @@
case kOnePassGood:
case kTwoPassGood: break;
case kRealTime: usage = AOM_USAGE_REALTIME; break;
+ case kAllIntra: usage = AOM_USAGE_ALL_INTRA; break;
default: ASSERT_TRUE(false) << "Unexpected mode " << mode;
}
mode_ = mode;
diff --git a/test/encode_test_driver.h b/test/encode_test_driver.h
index 3a443b4..5da3ac5 100644
--- a/test/encode_test_driver.h
+++ b/test/encode_test_driver.h
@@ -28,7 +28,7 @@
class CodecFactory;
class VideoSource;
-enum TestMode { kRealTime, kOnePassGood, kTwoPassGood };
+enum TestMode { kRealTime, kOnePassGood, kTwoPassGood, kAllIntra };
#define ALL_TEST_MODES \
::testing::Values(::libaom_test::kRealTime, ::libaom_test::kOnePassGood, \
::libaom_test::kTwoPassGood)
diff --git a/test/frame_size_tests.cc b/test/frame_size_tests.cc
index 6ee6d7d..4c8beb1 100644
--- a/test/frame_size_tests.cc
+++ b/test/frame_size_tests.cc
@@ -12,6 +12,7 @@
#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
#include "test/codec_factory.h"
#include "test/video_source.h"
+#include "test/util.h"
namespace {
@@ -71,5 +72,56 @@
expected_res_ = AOM_CODEC_OK;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
}
-#undef ONE_BY_ONE_VIDEO_NAME
+
+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)) {}
+ virtual ~AV1LosslessFrameSizeTests() {}
+
+ virtual void SetUp() { InitializeConfig(encoding_mode_); }
+
+ virtual bool HandleDecodeResult(const aom_codec_err_t res_dec,
+ libaom_test::Decoder *decoder) {
+ EXPECT_EQ(expected_res_, res_dec) << decoder->DecodeError();
+ return !::testing::Test::HasFailure();
+ }
+
+ virtual void PreEncodeFrameHook(::libaom_test::VideoSource *video,
+ ::libaom_test::Encoder *encoder) {
+ 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));
+
} // namespace