From 6bd56ae652a705de38e27f67a04172f5fe53ac03 Mon Sep 17 00:00:00 2001 From: Harish Mahendrakar Date: Wed, 27 Sep 2023 19:59:32 -0700 Subject: [PATCH] Rename AvcEncoderTest as AvcEncTest --- CMakeLists.txt | 2 +- tests/Android.bp | 4 +- tests/AndroidTest.xml | 10 +-- ...{AvcEncoderTest.cmake => AvcEncTest.cmake} | 8 +- tests/{AvcEncoderTest.cpp => AvcEncTest.cpp} | 74 +++++++++---------- tests/README.md | 18 ++--- ...AvcEncoderTestEnvironment.h => TestArgs.h} | 6 +- 7 files changed, 61 insertions(+), 61 deletions(-) rename tests/{AvcEncoderTest.cmake => AvcEncTest.cmake} (74%) rename tests/{AvcEncoderTest.cpp => AvcEncTest.cpp} (95%) rename tests/{AvcEncoderTestEnvironment.h => TestArgs.h} (89%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f9b2de1..d0c37d3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,5 +70,5 @@ if (${ENABLE_SVC}) endif() if (${ENABLE_TESTS}) - include("${AVC_ROOT}/tests/AvcEncoderTest.cmake") + include("${AVC_ROOT}/tests/AvcEncTest.cmake") endif() diff --git a/tests/Android.bp b/tests/Android.bp index 14ba11d1..656d3b7c 100644 --- a/tests/Android.bp +++ b/tests/Android.bp @@ -24,10 +24,10 @@ package { } cc_test { - name: "AvcEncoderTest", + name: "AvcEncTest", gtest: true, - srcs : [ "AvcEncoderTest.cpp" ], + srcs : [ "AvcEncTest.cpp" ], shared_libs: [ "libutils", diff --git a/tests/AndroidTest.xml b/tests/AndroidTest.xml index 6ad3f016..36d240d1 100644 --- a/tests/AndroidTest.xml +++ b/tests/AndroidTest.xml @@ -14,18 +14,18 @@ limitations under the License. --> - diff --git a/tests/AvcEncoderTest.cmake b/tests/AvcEncTest.cmake similarity index 74% rename from tests/AvcEncoderTest.cmake rename to tests/AvcEncTest.cmake index 685b0692..64a6924c 100644 --- a/tests/AvcEncoderTest.cmake +++ b/tests/AvcEncTest.cmake @@ -10,11 +10,11 @@ ExternalProject_Add(googletest list( APPEND - AVCENCODERTEST_SRCS - "${AVC_ROOT}/tests/AvcEncoderTest.cpp") + AVCENCTEST_SRCS + "${AVC_ROOT}/tests/AvcEncTest.cpp") -libavc_add_executable(AvcEncoderTest libavcenc SOURCES ${AVCENCODERTEST_SRCS}) -target_link_libraries(AvcEncoderTest +libavc_add_executable(AvcEncTest libavcenc SOURCES ${AVCENCTEST_SRCS}) +target_link_libraries(AvcEncTest ${AVC_ROOT}/third_party/build/googletest/src/googletest-build/lib/libgtest.a ${AVC_ROOT}/third_party/build/googletest/src/googletest-build/lib/libgtest_main.a ) diff --git a/tests/AvcEncoderTest.cpp b/tests/AvcEncTest.cpp similarity index 95% rename from tests/AvcEncoderTest.cpp rename to tests/AvcEncTest.cpp index cb067591..83ea7007 100644 --- a/tests/AvcEncoderTest.cpp +++ b/tests/AvcEncTest.cpp @@ -19,7 +19,7 @@ #include "ih264e.h" #include "ih264e_error.h" -#include "AvcEncoderTestEnvironment.h" +#include "TestArgs.h" #define MAX_FRAME_HEIGHT 1080 #define MAX_FRAME_WIDTH 1920 @@ -31,9 +31,9 @@ constexpr int16_t kCompressionRatio = 1; constexpr size_t kMinQP = 4; constexpr uint32_t kHeaderLength = 0x800; -static AvcEncoderTestEnvironment* gEnv = nullptr; +static TestArgs* gArgs = nullptr; -class AvcEncoderTest +class AvcEncTest : public ::testing::TestWithParam> { private: void setRawBuf(iv_raw_buf_t* psInpRawBuf, const uint8_t* data); @@ -106,10 +106,10 @@ class AvcEncoderTest IV_PROFILE_T mProfile = IV_PROFILE_BASE; public: - AvcEncoderTest() + AvcEncTest() : mInputBuffer(nullptr), mOutputBuffer(nullptr), mFpInput(nullptr), mFpOutput(nullptr) {} - ~AvcEncoderTest() { + ~AvcEncTest() { iv_mem_rec_t* ps_mem_rec = mMemRecords; for (size_t i = 0; i < mNumMemRecords; ++i) { if (ps_mem_rec) { @@ -127,12 +127,12 @@ class AvcEncoderTest tuple params = GetParam(); - mFileName = gEnv->getRes() + get<0>(params); + mFileName = gArgs->getRes() + get<0>(params); mFrameWidth = get<1>(params); mFrameHeight = get<2>(params); mFrameRate = get<3>(params); mBitRate = get<4>(params); - mOutFileName = gEnv->getRes() + "out.bin"; + mOutFileName = gArgs->getRes() + "out.bin"; ASSERT_LE(mFrameWidth, 1080) << "Frame Width <= 1080"; @@ -321,7 +321,7 @@ class AvcEncoderTest IV_STATUS_T status; }; -void AvcEncoderTest::setDimensions() { +void AvcEncTest::setDimensions() { ive_ctl_set_dimensions_ip_t sDimensionsIp = {}; ive_ctl_set_dimensions_op_t sDimensionsOp = {}; @@ -342,7 +342,7 @@ void AvcEncoderTest::setDimensions() { return; } -void AvcEncoderTest::setNumCores() { +void AvcEncTest::setNumCores() { ive_ctl_set_num_cores_ip_t sNumCoresIp = {}; ive_ctl_set_num_cores_op_t sNumCoresOp = {}; @@ -362,7 +362,7 @@ void AvcEncoderTest::setNumCores() { return; } -void AvcEncoderTest::setDefault() { +void AvcEncTest::setDefault() { ive_ctl_setdefault_ip_t sDefaultIp = {}; ive_ctl_setdefault_op_t sDefaultOp = {}; @@ -381,7 +381,7 @@ void AvcEncoderTest::setDefault() { return; } -void AvcEncoderTest::getBufInfo() { +void AvcEncTest::getBufInfo() { ih264e_ctl_getbufinfo_ip_t sGetBufInfoIp = {}; ih264e_ctl_getbufinfo_op_t sGetBufInfoOp = {}; @@ -400,7 +400,7 @@ void AvcEncoderTest::getBufInfo() { return; } -void AvcEncoderTest::setFrameRate() { +void AvcEncTest::setFrameRate() { ive_ctl_set_frame_rate_ip_t sFrameRateIp = {}; ive_ctl_set_frame_rate_op_t sFrameRateOp = {}; @@ -421,7 +421,7 @@ void AvcEncoderTest::setFrameRate() { return; } -void AvcEncoderTest::setIpeParams() { +void AvcEncTest::setIpeParams() { ive_ctl_set_ipe_params_ip_t sIpeParamsIp = {}; ive_ctl_set_ipe_params_op_t sIpeParamsOp = {}; @@ -443,7 +443,7 @@ void AvcEncoderTest::setIpeParams() { return; } -void AvcEncoderTest::setBitRate() { +void AvcEncTest::setBitRate() { ive_ctl_set_bitrate_ip_t sBitrateIp = {}; ive_ctl_set_bitrate_op_t sBitrateOp = {}; @@ -463,7 +463,7 @@ void AvcEncoderTest::setBitRate() { return; } -void AvcEncoderTest::setFrameType(IV_PICTURE_CODING_TYPE_T eFrameType) { +void AvcEncTest::setFrameType(IV_PICTURE_CODING_TYPE_T eFrameType) { ive_ctl_set_frame_type_ip_t sFrameTypeIp = {}; ive_ctl_set_frame_type_op_t sFrameTypeOp = {}; @@ -482,7 +482,7 @@ void AvcEncoderTest::setFrameType(IV_PICTURE_CODING_TYPE_T eFrameType) { return; } -void AvcEncoderTest::setQp() { +void AvcEncTest::setQp() { ive_ctl_set_qp_ip_t s_QpIp = {}; ive_ctl_set_qp_op_t s_QpOp = {}; @@ -513,7 +513,7 @@ void AvcEncoderTest::setQp() { return; } -void AvcEncoderTest::setEncMode(IVE_ENC_MODE_T eEncMode) { +void AvcEncTest::setEncMode(IVE_ENC_MODE_T eEncMode) { ive_ctl_set_enc_mode_ip_t sEncModeIp = {}; ive_ctl_set_enc_mode_op_t sEncModeOp = {}; @@ -533,7 +533,7 @@ void AvcEncoderTest::setEncMode(IVE_ENC_MODE_T eEncMode) { return; } -void AvcEncoderTest::setVbvParams() { +void AvcEncTest::setVbvParams() { ive_ctl_set_vbv_params_ip_t sVbvIp = {}; ive_ctl_set_vbv_params_op_t sVbvOp = {}; @@ -554,7 +554,7 @@ void AvcEncoderTest::setVbvParams() { return; } -void AvcEncoderTest::setAirParams() { +void AvcEncTest::setAirParams() { ive_ctl_set_air_params_ip_t sAirIp = {}; ive_ctl_set_air_params_op_t sAirOp = {}; @@ -575,7 +575,7 @@ void AvcEncoderTest::setAirParams() { return; } -void AvcEncoderTest::setMeParams() { +void AvcEncTest::setMeParams() { ive_ctl_set_me_params_ip_t sMeParamsIp = {}; ive_ctl_set_me_params_op_t sMeParamsOp = {}; @@ -602,7 +602,7 @@ void AvcEncoderTest::setMeParams() { return; } -void AvcEncoderTest::setGopParams() { +void AvcEncTest::setGopParams() { ive_ctl_set_gop_params_ip_t sGopParamsIp = {}; ive_ctl_set_gop_params_op_t sGopParamsOp = {}; @@ -624,7 +624,7 @@ void AvcEncoderTest::setGopParams() { return; } -void AvcEncoderTest::setProfileParams() { +void AvcEncTest::setProfileParams() { ive_ctl_set_profile_params_ip_t sProfileParamsIp = {}; ive_ctl_set_profile_params_op_t sProfileParamsOp = {}; @@ -649,7 +649,7 @@ void AvcEncoderTest::setProfileParams() { return; } -void AvcEncoderTest::setDeblockParams() { +void AvcEncTest::setDeblockParams() { ive_ctl_set_deblock_params_ip_t sDeblockParamsIp = {}; ive_ctl_set_deblock_params_op_t sDeblockParamsOp = {}; @@ -670,7 +670,7 @@ void AvcEncoderTest::setDeblockParams() { return; } -void AvcEncoderTest::setVuiParams() { +void AvcEncTest::setVuiParams() { ih264e_vui_ip_t sVuiParamsIp = {}; ih264e_vui_op_t sVuiParamsOp = {}; @@ -692,7 +692,7 @@ void AvcEncoderTest::setVuiParams() { return; } -void AvcEncoderTest::setSeiMdcvParams() { +void AvcEncTest::setSeiMdcvParams() { ih264e_ctl_set_sei_mdcv_params_ip_t sSeiMdcvParamsIp = {}; ih264e_ctl_set_sei_mdcv_params_op_t sSeiMdcvParamsOp = {}; @@ -721,7 +721,7 @@ void AvcEncoderTest::setSeiMdcvParams() { return; } -void AvcEncoderTest::setSeiCllParams() { +void AvcEncTest::setSeiCllParams() { ih264e_ctl_set_sei_cll_params_ip_t sSeiCllParamsIp = {}; ih264e_ctl_set_sei_cll_params_op_t sSeiCllParamsOp = {}; @@ -745,7 +745,7 @@ void AvcEncoderTest::setSeiCllParams() { return; } -void AvcEncoderTest::setSeiAveParams() { +void AvcEncTest::setSeiAveParams() { ih264e_ctl_set_sei_ave_params_ip_t sSeiAveParamsIp = {}; ih264e_ctl_set_sei_ave_params_op_t sSeiAveParamsOp = {}; @@ -770,7 +770,7 @@ void AvcEncoderTest::setSeiAveParams() { return; } -void AvcEncoderTest::setSeiCcvParams() { +void AvcEncTest::setSeiCcvParams() { ih264e_ctl_set_sei_ccv_params_ip_t sSeiCcvParamsIp = {}; ih264e_ctl_set_sei_ccv_params_op_t sSeiCcvParamsOp = {}; @@ -806,7 +806,7 @@ void AvcEncoderTest::setSeiCcvParams() { return; } -void AvcEncoderTest::logVersion() { +void AvcEncTest::logVersion() { ive_ctl_getversioninfo_ip_t sCtlIp = {}; ive_ctl_getversioninfo_op_t sCtlOp = {}; UWORD8 au1Buf[512]; @@ -825,7 +825,7 @@ void AvcEncoderTest::logVersion() { return; } -void AvcEncoderTest::encodeFrames(int64_t numFramesToEncode) { +void AvcEncTest::encodeFrames(int64_t numFramesToEncode) { ih264e_video_encode_ip_t ih264e_video_encode_ip = {}; ih264e_video_encode_op_t ih264e_video_encode_op = {}; @@ -916,7 +916,7 @@ void AvcEncoderTest::encodeFrames(int64_t numFramesToEncode) { } } -void AvcEncoderTest::setRawBuf(iv_raw_buf_t* psInpRawBuf, const uint8_t* data) { +void AvcEncTest::setRawBuf(iv_raw_buf_t* psInpRawBuf, const uint8_t* data) { switch (mIvVideoColorFormat) { case IV_YUV_420SP_UV: [[fallthrough]]; @@ -980,7 +980,7 @@ void AvcEncoderTest::setRawBuf(iv_raw_buf_t* psInpRawBuf, const uint8_t* data) { return; } -int64_t AvcEncoderTest::getTotalFrames() { +int64_t AvcEncTest::getTotalFrames() { struct stat buf; stat(mFileName.c_str(), &buf); size_t fileSize = buf.st_size; @@ -988,20 +988,20 @@ int64_t AvcEncoderTest::getTotalFrames() { return totalFrames; } -TEST_P(AvcEncoderTest, EncodeTest) { +TEST_P(AvcEncTest, EncodeTest) { ASSERT_NO_FATAL_FAILURE(encodeFrames(mTotalFrames)) << "Failed to Encode: " << mFileName; } -INSTANTIATE_TEST_SUITE_P(EncodeTest, AvcEncoderTest, +INSTANTIATE_TEST_SUITE_P(EncodeTest, AvcEncTest, ::testing::Values(make_tuple("bbb_352x288_420p_30fps_32frames.yuv", 352, 288, 30, 2048), make_tuple("football_qvga.yuv", 320, 240, 30, 1024))); int32_t main(int argc, char** argv) { - gEnv = new AvcEncoderTestEnvironment(); - ::testing::AddGlobalTestEnvironment(gEnv); + gArgs = new TestArgs(); + ::testing::AddGlobalTestEnvironment(gArgs); ::testing::InitGoogleTest(&argc, argv); - uint8_t status = gEnv->initFromOptions(argc, argv); + uint8_t status = gArgs->initFromOptions(argc, argv); if (status == 0) { status = RUN_ALL_TESTS(); } diff --git a/tests/README.md b/tests/README.md index b0b364f0..43aa2db0 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,4 +1,4 @@ -# AvcEncoderTest +# AvcEncTest The AvcEncoder Test Suite validates the Avc encoder. ## Linux x86/x64 @@ -38,27 +38,27 @@ Optionally, enable sanitizers by passing -DSANITIZE The media files for the tests are present [at](https://storage.googleapis.com/android_media/external/libavc/tests/AvcEncoder.zip). Download and extract these the current folder. -usage: AvcEncoderTest -P \ +usage: AvcEncTest -P \ ``` -$./AvcEncoderTest -P ./ +$./AvcEncTest -P ./ ``` ## Android Run the following steps to build the test suite: ``` -m AvcEncoderTest +m AvcEncTest ``` To test 64-bit binary push binaries from nativetest64. ``` -adb push ${OUT}/data/nativetest64/AvcEncoderTest/AvcEncoderTest /data/local/tmp/ +adb push ${OUT}/data/nativetest64/AvcEncTest/AvcEncTest /data/local/tmp/ ``` To test 32-bit binary push binaries from nativetest. ``` -adb push ${OUT}/data/nativetest/AvcEncoderTest/AvcEncoderTest /data/local/tmp/ +adb push ${OUT}/data/nativetest/AvcEncTest/AvcEncTest /data/local/tmp/ ``` The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/external/libavc/tests/AvcEncoder.zip) @@ -69,12 +69,12 @@ Download, unzip and push these files into device for testing. adb push AvcEncoder/. /data/local/tmp/ ``` -usage: AvcEncoderTest -P \ +usage: AvcEncTest -P \ ``` -adb shell /data/local/tmp/AvcEncoderTest -P /data/local/tmp/ +adb shell /data/local/tmp/AvcEncTest -P /data/local/tmp/ ``` Alternatively, the test can also be run using atest command. ``` -atest AvcEncoderTest -- --enable-module-dynamic-download=true +atest AvcEncTest -- --enable-module-dynamic-download=true ``` diff --git a/tests/AvcEncoderTestEnvironment.h b/tests/TestArgs.h similarity index 89% rename from tests/AvcEncoderTestEnvironment.h rename to tests/TestArgs.h index c3cb4349..684925c6 100644 --- a/tests/AvcEncoderTestEnvironment.h +++ b/tests/TestArgs.h @@ -22,9 +22,9 @@ using namespace std; -class AvcEncoderTestEnvironment : public::testing::Environment { +class TestArgs : public::testing::Environment { public: - AvcEncoderTestEnvironment() : res("/data/local/tmp/AvcEncoderTest/") {} + TestArgs() : res("/data/local/tmp/AvcEncTestRes/") {} // Parses the command line arguments int initFromOptions(int argc, char **argv); @@ -37,7 +37,7 @@ class AvcEncoderTestEnvironment : public::testing::Environment { string res; }; -int AvcEncoderTestEnvironment::initFromOptions(int argc, char **argv) { +int TestArgs::initFromOptions(int argc, char **argv) { static struct option options[] = {{"path", required_argument, 0, 'P'}, {0, 0, 0, 0}}; while (true) {