From: Jerome Jiang Date: Mon, 10 Dec 2018 20:53:20 +0000 (-0800) Subject: Refactor svc_*_test.cc X-Git-Tag: v1.8.0~81^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=36f523e213c9b3c86ca9075b75af364d43706cff;p=libvpx Refactor svc_*_test.cc Put test classes into svc_test namespace. Make num_nonref_frames_ and mismatched_nframes private, as they're computed by encoder/decoder hooks which shouldn't be modified outside the class. Add accessor to num_nonref_frames_. Change-Id: I3836a45426796ba6a8c98dd31e21b5aec4b8abf4 --- diff --git a/test/svc_datarate_test.cc b/test/svc_datarate_test.cc index b08666672..6a8ff93a1 100644 --- a/test/svc_datarate_test.cc +++ b/test/svc_datarate_test.cc @@ -19,9 +19,10 @@ #include "vpx/vpx_codec.h" #include "vpx_ports/bitops.h" +namespace svc_test { namespace { -class DatarateOnePassCbrSvc : public ::svc_test::OnePassCbrSvc { +class DatarateOnePassCbrSvc : public OnePassCbrSvc { public: explicit DatarateOnePassCbrSvc(const ::libvpx_test::CodecFactory *codec) : OnePassCbrSvc(codec) { @@ -498,6 +499,7 @@ class DatarateOnePassCbrSvc : public ::svc_test::OnePassCbrSvc { } unsigned int GetMismatchFrames() { return mismatch_nframes_; } + unsigned int GetNonRefFrames() { return num_nonref_frames_; } vpx_codec_pts_t last_pts_; double timebase_; @@ -506,7 +508,6 @@ class DatarateOnePassCbrSvc : public ::svc_test::OnePassCbrSvc { double file_datarate_[VPX_MAX_LAYERS]; size_t bits_in_last_frame_; double mismatch_psnr_; - int mismatch_nframes_; int denoiser_on_; int tune_content_; int spatial_layer_id_; @@ -520,7 +521,6 @@ class DatarateOnePassCbrSvc : public ::svc_test::OnePassCbrSvc { int middle_bitrate_; int top_bitrate_; int key_frame_spacing_; - unsigned int num_nonref_frames_; int layer_framedrop_; int force_key_; int force_key_test_; @@ -555,6 +555,9 @@ class DatarateOnePassCbrSvc : public ::svc_test::OnePassCbrSvc { cfg_.temporal_layering_mode = 0; } } + + unsigned int num_nonref_frames_; + unsigned int mismatch_nframes_; }; // Params: speed setting. @@ -603,7 +606,7 @@ TEST_P(DatarateOnePassCbrSvcSingleBR, OnePassCbrSvc2SL1TLScreenContent1) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -632,7 +635,7 @@ TEST_P(DatarateOnePassCbrSvcSingleBR, OnePassCbrSvc3SL3TLForceKey) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -665,7 +668,7 @@ TEST_P(DatarateOnePassCbrSvcSingleBR, OnePassCbrSvc3SL2TLDynamicPatternChange) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -701,7 +704,7 @@ TEST_P(DatarateOnePassCbrSvcSingleBR, #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -739,7 +742,7 @@ TEST_P(DatarateOnePassCbrSvcSingleBR, #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -774,7 +777,7 @@ TEST_P(DatarateOnePassCbrSvcSingleBR, OnePassCbrSvc3SL_DisableEnableLayers) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -824,7 +827,7 @@ TEST_P(DatarateOnePassCbrSvcSingleBR, OnePassCbrSvc2SL1TL5x5MultipleRuns) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -875,7 +878,7 @@ TEST_P(DatarateOnePassCbrSvcMultiBR, OnePassCbrSvc2SL3TL) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -926,7 +929,7 @@ TEST_P(DatarateOnePassCbrSvcFrameDropMultiBR, OnePassCbrSvc2SL3TL4Threads) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -957,7 +960,7 @@ TEST_P(DatarateOnePassCbrSvcFrameDropMultiBR, OnePassCbrSvc3SL3TL4Threads) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -1009,7 +1012,7 @@ TEST_P(DatarateOnePassCbrSvcInterLayerPredSingleBR, OnePassCbrSvc3SL3TL) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -1040,7 +1043,7 @@ TEST_P(DatarateOnePassCbrSvcSingleBR, OnePassCbrSvc3SL3TLDynamicBitrateChange) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -1097,7 +1100,7 @@ TEST_P(DatarateOnePassCbrSvcDenoiser, OnePassCbrSvc2SL3TLDenoiserOn) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } #endif @@ -1151,7 +1154,7 @@ TEST_P(DatarateOnePassCbrSvcSmallKF, OnePassCbrSvc3SL3TLSmallKf) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -1184,7 +1187,7 @@ TEST_P(DatarateOnePassCbrSvcSmallKF, OnePassCbrSvc2SL3TLSmallKf) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -1216,7 +1219,7 @@ TEST_P(DatarateOnePassCbrSvcSingleBR, OnePassCbrSvc3SL3TLSyncFrames) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -1249,7 +1252,7 @@ TEST_P(DatarateOnePassCbrSvcSingleBR, OnePassCbrSvc3SL1TLSyncWithIntraOnly) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -1302,7 +1305,7 @@ TEST_P(DatarateOnePassCbrSvcSingleBR, OnePassCbrSvc2QL1TLScreen) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -1376,7 +1379,7 @@ TEST_P(DatarateOnePassCbrSvcPostencodeDrop, OnePassCbrSvc2QL1TLScreen) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -1405,3 +1408,4 @@ VP9_INSTANTIATE_TEST_CASE(DatarateOnePassCbrSvcDenoiser, VP9_INSTANTIATE_TEST_CASE(DatarateOnePassCbrSvcSmallKF, ::testing::Range(5, 10), ::testing::Range(32, 36)); } // namespace +} // namespace svc_test diff --git a/test/svc_end_to_end_test.cc b/test/svc_end_to_end_test.cc index 86a350e0f..388268e5c 100644 --- a/test/svc_end_to_end_test.cc +++ b/test/svc_end_to_end_test.cc @@ -18,10 +18,11 @@ #include "vpx/vpx_codec.h" #include "vpx_ports/bitops.h" +namespace svc_test { namespace { class ScalePartitionOnePassCbrSvc - : public ::svc_test::OnePassCbrSvc, + : public OnePassCbrSvc, public ::testing::TestWithParam { public: ScalePartitionOnePassCbrSvc() @@ -60,7 +61,9 @@ class ScalePartitionOnePassCbrSvc virtual void SetConfig(int /* num_temporal_layer*/) {} unsigned int GetMismatchFrames() const { return mismatch_nframes_; } + unsigned int GetNonRefFrames() const { return num_nonref_frames_; } + private: unsigned int mismatch_nframes_; unsigned int num_nonref_frames_; }; @@ -92,20 +95,20 @@ TEST_P(ScalePartitionOnePassCbrSvc, OnePassCbrSvc3SL3TL1080P) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } // Params: Inter layer prediction modes. -class SyncFrameOnePassCbrSvc : public ::svc_test::OnePassCbrSvc, +class SyncFrameOnePassCbrSvc : public OnePassCbrSvc, public ::libvpx_test::CodecTestWithParam { public: SyncFrameOnePassCbrSvc() : OnePassCbrSvc(GET_PARAM(0)), current_video_frame_(0), - frame_to_start_decode_(0), frame_to_sync_(0), mismatch_nframes_(0), - num_nonref_frames_(0), inter_layer_pred_mode_(GET_PARAM(1)), - decode_to_layer_before_sync_(-1), decode_to_layer_after_sync_(-1), - denoiser_on_(0), intra_only_test_(false) { + frame_to_start_decode_(0), frame_to_sync_(0), + inter_layer_pred_mode_(GET_PARAM(1)), decode_to_layer_before_sync_(-1), + decode_to_layer_after_sync_(-1), denoiser_on_(0), + intra_only_test_(false), mismatch_nframes_(0), num_nonref_frames_(0) { SetMode(::libvpx_test::kRealTime); memset(&svc_layer_sync_, 0, sizeof(svc_layer_sync_)); } @@ -185,12 +188,11 @@ class SyncFrameOnePassCbrSvc : public ::svc_test::OnePassCbrSvc, } unsigned int GetMismatchFrames() const { return mismatch_nframes_; } + unsigned int GetNonRefFrames() const { return num_nonref_frames_; } unsigned int current_video_frame_; unsigned int frame_to_start_decode_; unsigned int frame_to_sync_; - unsigned int mismatch_nframes_; - unsigned int num_nonref_frames_; int inter_layer_pred_mode_; int decode_to_layer_before_sync_; int decode_to_layer_after_sync_; @@ -225,6 +227,9 @@ class SyncFrameOnePassCbrSvc : public ::svc_test::OnePassCbrSvc, cfg_.temporal_layering_mode = 1; } } + + unsigned int mismatch_nframes_; + unsigned int num_nonref_frames_; }; // Test for sync layer for 1 pass CBR SVC: 3 spatial layers and @@ -251,7 +256,7 @@ TEST_P(SyncFrameOnePassCbrSvc, OnePassCbrSvc3SL3TLFullSync) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -278,7 +283,7 @@ TEST_P(SyncFrameOnePassCbrSvc, OnePassCbrSvc2SL3TLSyncToVGA) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -305,7 +310,7 @@ TEST_P(SyncFrameOnePassCbrSvc, OnePassCbrSvc3SL3TLSyncToHD) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -332,7 +337,7 @@ TEST_P(SyncFrameOnePassCbrSvc, OnePassCbrSvc3SL3TLSyncToVGAHD) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -361,7 +366,7 @@ TEST_P(SyncFrameOnePassCbrSvc, OnePassCbrSvc2SL3TLSyncFrameVGADenoise) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } #endif @@ -391,7 +396,7 @@ TEST_P(SyncFrameOnePassCbrSvc, OnePassCbrSvc3SL3TLSyncFrameIntraOnlyQVGA) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -420,7 +425,7 @@ TEST_P(SyncFrameOnePassCbrSvc, OnePassCbrSvc3SL3TLSyncFrameIntraOnlyVGA) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -445,7 +450,7 @@ TEST_P(SyncFrameOnePassCbrSvc, OnePassCbrSvc1SL3TLSyncFrameIntraOnlyQVGA) { #if CONFIG_VP9_DECODER // The non-reference frames are expected to be mismatched frames as the // encoder will avoid loopfilter on these frames. - EXPECT_EQ(num_nonref_frames_, GetMismatchFrames()); + EXPECT_EQ(GetNonRefFrames(), GetMismatchFrames()); #endif } @@ -457,3 +462,4 @@ INSTANTIATE_TEST_CASE_P( static_cast(&libvpx_test::kVP9))); } // namespace +} // namespace svc_test