From 46bfeed2c9a7e52c8d1624f9e388af137e02ff19 Mon Sep 17 00:00:00 2001 From: Wan-Teh Chang Date: Fri, 10 Jun 2022 13:52:31 -0700 Subject: Convert EncoderTest::last_pts_ to a local variable Convert the data member EncoderTest::last_pts_ to a local variable in the EncoderTest::RunLoop() and VP9FrameSizeTestsLarge::RunLoop() methods. EncoderTest::last_pts_ is only used in these two methods, and these two methods first set EncoderTest::last_pts_ to 0 before using it. So EncoderTest::last_pts_ is effectively a local variable in these two methods. Note that several subclasses of EncoderTest declare their own last_pts_ data member and use it to calculate the data rate. Apparently their own last_pts_ data member hides the same-named data member in the base class. Although this is allowed by C++, this is very confusing. Change-Id: I55ce1cf8cc62e07333d8a902d65b46343a3d5881 --- test/encode_test_driver.cc | 6 +++--- test/encode_test_driver.h | 4 +--- test/frame_size_tests.cc | 6 +++--- 3 files changed, 7 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/test/encode_test_driver.cc b/test/encode_test_driver.cc index 1ce39eaef..9ca15ae4d 100644 --- a/test/encode_test_driver.cc +++ b/test/encode_test_driver.cc @@ -169,7 +169,7 @@ void EncoderTest::RunLoop(VideoSource *video) { ASSERT_TRUE(passes_ == 1 || passes_ == 2); for (unsigned int pass = 0; pass < passes_; pass++) { - last_pts_ = 0; + vpx_codec_pts_t last_pts = 0; if (passes_ == 1) { cfg_.g_pass = VPX_RC_ONE_PASS; @@ -225,8 +225,8 @@ void EncoderTest::RunLoop(VideoSource *video) { has_dxdata = true; } - ASSERT_GE(pkt->data.frame.pts, last_pts_); - last_pts_ = pkt->data.frame.pts; + ASSERT_GE(pkt->data.frame.pts, last_pts); + last_pts = pkt->data.frame.pts; FramePktHook(pkt); break; diff --git a/test/encode_test_driver.h b/test/encode_test_driver.h index 7085945f6..f6bb841d8 100644 --- a/test/encode_test_driver.h +++ b/test/encode_test_driver.h @@ -206,8 +206,7 @@ class Encoder { class EncoderTest { protected: explicit EncoderTest(const CodecFactory *codec) - : codec_(codec), abort_(false), init_flags_(0), frame_flags_(0), - last_pts_(0) { + : codec_(codec), abort_(false), init_flags_(0), frame_flags_(0) { // Default to 1 thread. cfg_.g_threads = 1; } @@ -291,7 +290,6 @@ class EncoderTest { TwopassStatsStore stats_; unsigned long init_flags_; unsigned long frame_flags_; - vpx_codec_pts_t last_pts_; }; } // namespace libvpx_test diff --git a/test/frame_size_tests.cc b/test/frame_size_tests.cc index d85c193e0..8a0eb71ba 100644 --- a/test/frame_size_tests.cc +++ b/test/frame_size_tests.cc @@ -111,7 +111,7 @@ class VP9FrameSizeTestsLarge : public ::libvpx_test::EncoderTest, ASSERT_TRUE(passes_ == 1 || passes_ == 2); for (unsigned int pass = 0; pass < passes_; pass++) { - last_pts_ = 0; + vpx_codec_pts_t last_pts = 0; if (passes_ == 1) { cfg_.g_pass = VPX_RC_ONE_PASS; @@ -144,8 +144,8 @@ class VP9FrameSizeTestsLarge : public ::libvpx_test::EncoderTest, again = true; switch (pkt->kind) { case VPX_CODEC_CX_FRAME_PKT: - ASSERT_GE(pkt->data.frame.pts, last_pts_); - last_pts_ = pkt->data.frame.pts; + ASSERT_GE(pkt->data.frame.pts, last_pts); + last_pts = pkt->data.frame.pts; FramePktHook(pkt); break; -- cgit v1.2.3