ref: 1c6203192dbce464546674508790ffedc3cc3e6c
parent: 1d9e2b50031f6e43f5d696426beb97f1ae4a7ce1
author: James Zern <[email protected]>
date: Tue Aug 12 15:26:49 EDT 2014
cq_test: allow test cases to be run out of order check that bitrates increase with cqlevel at global test case teardown, rather than after each individual test case. this allows the tests to be run out of order with --gtest_shuffle. Change-Id: I9e0d4e6a2d920a1f2fe9aee7b7876a3e7eb5d297
--- a/test/cq_test.cc
+++ b/test/cq_test.cc
@@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include <cmath>
+#include <map>
#include "third_party/googletest/src/include/gtest/gtest.h"
#include "test/codec_factory.h"
#include "test/encode_test_driver.h"
@@ -24,6 +25,28 @@
class CQTest : public ::libvpx_test::EncoderTest,
public ::libvpx_test::CodecTestWithParam<int> {
+ public:
+ // maps the cqlevel to the bitrate produced.
+ typedef std::map<int, uint32_t> BitrateMap;
+
+ static void SetUpTestCase() {
+ bitrates_.clear();
+ }
+
+ static void TearDownTestCase() {
+ ASSERT_TRUE(!HasFailure())
+ << "skipping bitrate validation due to earlier failure.";
+ uint32_t prev_actual_bitrate = kCQTargetBitrate;
+ for (BitrateMap::const_iterator iter = bitrates_.begin();
+ iter != bitrates_.end(); ++iter) {
+ const uint32_t cq_actual_bitrate = iter->second;
+ EXPECT_LE(cq_actual_bitrate, prev_actual_bitrate)
+ << "cq_level: " << iter->first
+ << ", bitrate should decrease with increase in CQ level.";
+ prev_actual_bitrate = cq_actual_bitrate;
+ }
+ }
+
protected:
CQTest() : EncoderTest(GET_PARAM(0)), cq_level_(GET_PARAM(1)) {
init_flags_ = VPX_CODEC_USE_PSNR;
@@ -66,9 +89,12 @@
return pow(10.0, avg_psnr / 10.0) / file_size_;
}
+ int cq_level() const { return cq_level_; }
size_t file_size() const { return file_size_; }
int n_frames() const { return n_frames_; }
+ static BitrateMap bitrates_;
+
private:
int cq_level_;
size_t file_size_;
@@ -76,7 +102,8 @@
int n_frames_;
};
-unsigned int prev_actual_bitrate = kCQTargetBitrate;
+CQTest::BitrateMap CQTest::bitrates_;
+
TEST_P(CQTest, LinearPSNRIsHigherForCQLevel) {
const vpx_rational timebase = { 33333333, 1000000000 };
cfg_.g_timebase = timebase;
@@ -91,8 +118,7 @@
const unsigned int cq_actual_bitrate =
static_cast<unsigned int>(file_size()) * 8 * 30 / (n_frames() * 1000);
EXPECT_LE(cq_actual_bitrate, kCQTargetBitrate);
- EXPECT_LE(cq_actual_bitrate, prev_actual_bitrate);
- prev_actual_bitrate = cq_actual_bitrate;
+ bitrates_[cq_level()] = cq_actual_bitrate;
// try targeting the approximate same bitrate with VBR mode
cfg_.rc_end_usage = VPX_VBR;