Showing the changes to test/api/decoder_test.cpp (1 of 55 files). Show all
Unified · Split
| @@ -1,136 +1,138 @@ | ||
| 1 | −#include <gtest/gtest.h> | |
| 2 | −#include "utils/HashFunctions.h" | |
| 3 | −#include "BaseDecoderTest.h" | |
| 4 | −#include <string> | |
| 5 | − | |
| 6 | −static void UpdateHashFromPlane (SHA1Context* ctx, const uint8_t* plane, | |
| 7 | − int width, int height, int stride) { | |
| 8 | − for (int i = 0; i < height; i++) { | |
| 9 | − SHA1Input (ctx, plane, width); | |
| 10 | − plane += stride; | |
| 11 | − } | |
| 12 | −} | |
| 13 | − | |
| 14 | −class DecoderCapabilityTest : public ::testing::Test { | |
| 15 | − public: | |
| 16 | − virtual void SetUp() {} | |
| 17 | − virtual void TearDown() {} | |
| 18 | −}; | |
| 19 | − | |
| 20 | −TEST_F (DecoderCapabilityTest, JustInit) { | |
| 21 | − SDecoderCapability sDecCap; | |
| 22 | − int iRet = WelsGetDecoderCapability (&sDecCap); | |
| 23 | − ASSERT_TRUE (iRet == 0); | |
| 24 | − EXPECT_EQ (sDecCap.iProfileIdc, 66); | |
| 25 | − EXPECT_EQ (sDecCap.iProfileIop, 0xE0); | |
| 26 | − EXPECT_EQ (sDecCap.iLevelIdc, 32); | |
| 27 | − EXPECT_EQ (sDecCap.iMaxMbps, 216000); | |
| 28 | − EXPECT_EQ (sDecCap.iMaxFs, 5120); | |
| 29 | − EXPECT_EQ (sDecCap.iMaxCpb, 20000); | |
| 30 | − EXPECT_EQ (sDecCap.iMaxDpb, 20480); | |
| 31 | − EXPECT_EQ (sDecCap.iMaxBr, 20000); | |
| 32 | − EXPECT_EQ (sDecCap.bRedPicCap, false); | |
| 33 | −} | |
| 34 | − | |
| 35 | − | |
| 36 | −class DecoderInitTest : public ::testing::Test, public BaseDecoderTest { | |
| 37 | − public: | |
| 38 | − virtual void SetUp() { | |
| 39 | − BaseDecoderTest::SetUp(); | |
| 40 | − } | |
| 41 | − virtual void TearDown() { | |
| 42 | − BaseDecoderTest::TearDown(); | |
| 43 | − } | |
| 44 | −}; | |
| 45 | − | |
| 46 | −TEST_F (DecoderInitTest, JustInit) {} | |
| 47 | − | |
| 48 | −struct FileParam { | |
| 49 | − const char* fileName; | |
| 50 | − const char* hashStr; | |
| 51 | −}; | |
| 52 | − | |
| 53 | −class DecoderOutputTest : public ::testing::WithParamInterface<FileParam>, | |
| 54 | − public DecoderInitTest, public BaseDecoderTest::Callback { | |
| 55 | − public: | |
| 56 | − virtual void SetUp() { | |
| 57 | − DecoderInitTest::SetUp(); | |
| 58 | − if (HasFatalFailure()) { | |
| 59 | − return; | |
| 60 | − } | |
| 61 | − SHA1Reset (&ctx_); | |
| 62 | − } | |
| 63 | − virtual void onDecodeFrame (const Frame& frame) { | |
| 64 | − const Plane& y = frame.y; | |
| 65 | − const Plane& u = frame.u; | |
| 66 | − const Plane& v = frame.v; | |
| 67 | − UpdateHashFromPlane (&ctx_, y.data, y.width, y.height, y.stride); | |
| 68 | − UpdateHashFromPlane (&ctx_, u.data, u.width, u.height, u.stride); | |
| 69 | − UpdateHashFromPlane (&ctx_, v.data, v.width, v.height, v.stride); | |
| 70 | − } | |
| 71 | − protected: | |
| 72 | − SHA1Context ctx_; | |
| 73 | −}; | |
| 74 | − | |
| 75 | −TEST_P (DecoderOutputTest, CompareOutput) { | |
| 76 | − FileParam p = GetParam(); | |
| 77 | −#if defined(ANDROID_NDK) | |
| 78 | − std::string filename = std::string ("/sdcard/") + p.fileName; | |
| 79 | − DecodeFile (filename.c_str(), this); | |
| 80 | −#else | |
| 81 | − DecodeFile (p.fileName, this); | |
| 82 | −#endif | |
| 83 | − | |
| 84 | − unsigned char digest[SHA_DIGEST_LENGTH]; | |
| 85 | − SHA1Result (&ctx_, digest); | |
| 86 | − if (!HasFatalFailure()) { | |
| 87 | − CompareHash (digest, p.hashStr); | |
| 88 | − } | |
| 89 | −} | |
| 90 | −static const FileParam kFileParamArray[] = { | |
| 91 | − {"res/Adobe_PDF_sample_a_1024x768_50Frms.264", "9aa9a4d9598eb3e1093311826844f37c43e4c521"}, | |
| 92 | − {"res/BA1_FT_C.264", "418d152fb85709b6f172799dcb239038df437cfa"}, | |
| 93 | − {"res/BA1_Sony_D.jsv", "d94b5ceed5686a03ea682b53d415dee999d27eb6"}, | |
| 94 | − {"res/BAMQ1_JVC_C.264", "613cf662c23e5d9e1d7da7fe880a3c427411d171"}, | |
| 95 | − {"res/BAMQ2_JVC_C.264", "11bcf3713f520e606a8326d37e00e5fd6c9fd4a0"}, | |
| 96 | − {"res/BA_MW_D.264", "afd7a9765961ca241bb4bdf344b31397bec7465a"}, | |
| 97 | − {"res/BANM_MW_D.264", "92d924a857a1a7d7d9b224eaa3887830f15dee7f"}, | |
| 98 | − {"res/BASQP1_Sony_C.jsv", "3986c8c9d2876d2f0748b925101b152c6ec8b811"}, | |
| 99 | − {"res/CI1_FT_B.264", "cbfec15e17a504678b19a1191992131c92a1ac26"}, | |
| 100 | − {"res/CI_MW_D.264", "289f29a103c8d95adf2909c646466904be8b06d7"}, | |
| 101 | − {"res/CVFC1_Sony_C.jsv", "4641abd7419a5580b97f16e83fd1d566339229d0"}, | |
| 102 | − {"res/CVPCMNL1_SVA_C.264", "c2b0d964de727c64b9fccb58f63b567c82bda95a"}, | |
| 103 | − {"res/LS_SVA_D.264", "72118f4d1674cf14e58bed7e67cb3aeed3df62b9"}, | |
| 104 | − {"res/MIDR_MW_D.264", "9467030f4786f75644bf06a7fc809c36d1959827"}, | |
| 105 | − {"res/MPS_MW_A.264", "67f1cfbef0e8025ed60dedccf8d9558d0636be5f"}, | |
| 106 | − {"res/MR1_BT_A.h264", "6e585f8359667a16b03e5f49a06f5ceae8d991e0"}, | |
| 107 | − {"res/MR1_MW_A.264", "d9e2bf34e9314dcc171ddaea2c5015d0421479f2"}, | |
| 108 | − {"res/MR2_MW_A.264", "628b1d4eff04c2d277f7144e23484957dad63cbe"}, | |
| 109 | − {"res/MR2_TANDBERG_E.264", "74d618bc7d9d41998edf4c85d51aa06111db6609"}, | |
| 110 | − {"res/NL1_Sony_D.jsv", "e401e30669938443c2f02522fd4d5aa1382931a0"}, | |
| 111 | − {"res/NLMQ1_JVC_C.264", "f3265c6ddf8db1b2bf604d8a2954f75532e28cda"}, | |
| 112 | − {"res/NLMQ2_JVC_C.264", "350ae86ef9ba09390d63a09b7f9ff54184109ca8"}, | |
| 113 | − {"res/NRF_MW_E.264", "20732198c04cd2591350a361e4510892f6eed3f0"}, | |
| 114 | − {"res/QCIF_2P_I_allIPCM.264", "8724c0866ebdba7ebb7209a0c0c3ae3ae38a0240"}, | |
| 115 | − {"res/SVA_BA1_B.264", "c4543b24823b16c424c673616c36c7f537089b2d"}, | |
| 116 | − {"res/SVA_BA2_D.264", "98ff2d67860462d8d8bcc9352097c06cc401d97e"}, | |
| 117 | − {"res/SVA_Base_B.264", "91f514d81cd33de9f6fbf5dbefdb189cc2e7ecf4"}, | |
| 118 | − {"res/SVA_CL1_E.264", "4fe09ab6cdc965ea10a20f1d6dd38aca954412bb"}, | |
| 119 | − {"res/SVA_FM1_E.264", "fad08c4ff7cf2307b6579853d0f4652fc26645d3"}, | |
| 120 | − {"res/SVA_NL1_B.264", "6d63f72a0c0d833b1db0ba438afff3b4180fb3e6"}, | |
| 121 | − {"res/SVA_NL2_E.264", "70453ef8097c94dd190d6d2d1d5cb83c67e66238"}, | |
| 122 | − {"res/SarVui.264", "98ff2d67860462d8d8bcc9352097c06cc401d97e"}, | |
| 123 | − {"res/Static.264", "91dd4a7a796805b2cd015cae8fd630d96c663f42"}, | |
| 124 | − {"res/Zhling_1280x720.264", "ad99f5eaa2d73ae3840e7da67313de8cfc866ce6"}, | |
| 125 | − {"res/sps_subsetsps_bothVUI.264", "d3a47032eb5dcc1963343a68e9bea12435bf1e4c"}, | |
| 126 | − {"res/test_cif_I_CABAC_PCM.264", "95fdf21470d3bbcf95505abb2164042063a79d98"}, | |
| 127 | − {"res/test_cif_I_CABAC_slice.264", "19121bc67f2b13fb8f030504fc0827e1ac6d0fdb"}, | |
| 128 | − {"res/test_cif_P_CABAC_slice.264", "521bbd0ba2422369b724c7054545cf107a56f959"}, | |
| 129 | − {"res/test_qcif_cabac.264", "587d1d05943f3cd416bf69469975fdee05361e69"}, | |
| 130 | − {"res/test_scalinglist_jm.264", "f690a3af2896a53360215fb5d35016bfd41499b3"}, | |
| 131 | − {"res/test_vd_1d.264", "5827d2338b79ff82cd091c707823e466197281d3"}, | |
| 132 | − {"res/test_vd_rc.264", "eea02e97bfec89d0418593a8abaaf55d02eaa1ca"}, | |
| 133 | −}; | |
| 134 | − | |
| 135 | −INSTANTIATE_TEST_CASE_P (DecodeFile, DecoderOutputTest, | |
| 136 | − ::testing::ValuesIn (kFileParamArray)); | |
| 1 | +#include <gtest/gtest.h> | |
| 2 | +#include "utils/HashFunctions.h" | |
| 3 | +#include "BaseDecoderTest.h" | |
| 4 | +#include <string> | |
| 5 | + | |
| 6 | +static void UpdateHashFromPlane (SHA1Context* ctx, const uint8_t* plane, | |
| 7 | + int width, int height, int stride) { | |
| 8 | + for (int i = 0; i < height; i++) { | |
| 9 | + SHA1Input (ctx, plane, width); | |
| 10 | + plane += stride; | |
| 11 | + } | |
| 12 | +} | |
| 13 | + | |
| 14 | +class DecoderCapabilityTest : public ::testing::Test { | |
| 15 | + public: | |
| 16 | + virtual void SetUp() {} | |
| 17 | + virtual void TearDown() {} | |
| 18 | +}; | |
| 19 | + | |
| 20 | +TEST_F (DecoderCapabilityTest, JustInit) { | |
| 21 | + SDecoderCapability sDecCap; | |
| 22 | + int iRet = WelsGetDecoderCapability (&sDecCap); | |
| 23 | + ASSERT_TRUE (iRet == 0); | |
| 24 | + EXPECT_EQ (sDecCap.iProfileIdc, 66); | |
| 25 | + EXPECT_EQ (sDecCap.iProfileIop, 0xE0); | |
| 26 | + EXPECT_EQ (sDecCap.iLevelIdc, 32); | |
| 27 | + EXPECT_EQ (sDecCap.iMaxMbps, 216000); | |
| 28 | + EXPECT_EQ (sDecCap.iMaxFs, 5120); | |
| 29 | + EXPECT_EQ (sDecCap.iMaxCpb, 20000); | |
| 30 | + EXPECT_EQ (sDecCap.iMaxDpb, 20480); | |
| 31 | + EXPECT_EQ (sDecCap.iMaxBr, 20000); | |
| 32 | + EXPECT_EQ (sDecCap.bRedPicCap, false); | |
| 33 | +} | |
| 34 | + | |
| 35 | + | |
| 36 | +class DecoderInitTest : public ::testing::Test, public BaseDecoderTest { | |
| 37 | + public: | |
| 38 | + virtual void SetUp() { | |
| 39 | + BaseDecoderTest::SetUp(); | |
| 40 | + } | |
| 41 | + virtual void TearDown() { | |
| 42 | + BaseDecoderTest::TearDown(); | |
| 43 | + } | |
| 44 | +}; | |
| 45 | + | |
| 46 | +TEST_F (DecoderInitTest, JustInit) {} | |
| 47 | + | |
| 48 | +struct FileParam { | |
| 49 | + const char* fileName; | |
| 50 | + const char* hashStr; | |
| 51 | +}; | |
| 52 | + | |
| 53 | +class DecoderOutputTest : public ::testing::WithParamInterface<FileParam>, | |
| 54 | + public DecoderInitTest, public BaseDecoderTest::Callback { | |
| 55 | + public: | |
| 56 | + virtual void SetUp() { | |
| 57 | + DecoderInitTest::SetUp(); | |
| 58 | + if (HasFatalFailure()) { | |
| 59 | + return; | |
| 60 | + } | |
| 61 | + SHA1Reset (&ctx_); | |
| 62 | + } | |
| 63 | + virtual void onDecodeFrame (const Frame& frame) { | |
| 64 | + const Plane& y = frame.y; | |
| 65 | + const Plane& u = frame.u; | |
| 66 | + const Plane& v = frame.v; | |
| 67 | + UpdateHashFromPlane (&ctx_, y.data, y.width, y.height, y.stride); | |
| 68 | + UpdateHashFromPlane (&ctx_, u.data, u.width, u.height, u.stride); | |
| 69 | + UpdateHashFromPlane (&ctx_, v.data, v.width, v.height, v.stride); | |
| 70 | + } | |
| 71 | + protected: | |
| 72 | + SHA1Context ctx_; | |
| 73 | +}; | |
| 74 | + | |
| 75 | +TEST_P (DecoderOutputTest, CompareOutput) { | |
| 76 | + FileParam p = GetParam(); | |
| 77 | +#if defined(ANDROID_NDK) | |
| 78 | + std::string filename = std::string ("/sdcard/") + p.fileName; | |
| 79 | + DecodeFile (filename.c_str(), this); | |
| 80 | +#else | |
| 81 | + DecodeFile (p.fileName, this); | |
| 82 | +#endif | |
| 83 | + | |
| 84 | + unsigned char digest[SHA_DIGEST_LENGTH]; | |
| 85 | + SHA1Result (&ctx_, digest); | |
| 86 | + if (!HasFatalFailure()) { | |
| 87 | + CompareHash (digest, p.hashStr); | |
| 88 | + } | |
| 89 | +} | |
| 90 | +static const FileParam kFileParamArray[] = { | |
| 91 | + {"res/Adobe_PDF_sample_a_1024x768_50Frms.264", "9aa9a4d9598eb3e1093311826844f37c43e4c521"}, | |
| 92 | + {"res/BA1_FT_C.264", "418d152fb85709b6f172799dcb239038df437cfa"}, | |
| 93 | + {"res/BA1_Sony_D.jsv", "d94b5ceed5686a03ea682b53d415dee999d27eb6"}, | |
| 94 | + {"res/BAMQ1_JVC_C.264", "613cf662c23e5d9e1d7da7fe880a3c427411d171"}, | |
| 95 | + {"res/BAMQ2_JVC_C.264", "11bcf3713f520e606a8326d37e00e5fd6c9fd4a0"}, | |
| 96 | + {"res/BA_MW_D.264", "afd7a9765961ca241bb4bdf344b31397bec7465a"}, | |
| 97 | + {"res/BANM_MW_D.264", "92d924a857a1a7d7d9b224eaa3887830f15dee7f"}, | |
| 98 | + {"res/BASQP1_Sony_C.jsv", "3986c8c9d2876d2f0748b925101b152c6ec8b811"}, | |
| 99 | + {"res/CI1_FT_B.264", "cbfec15e17a504678b19a1191992131c92a1ac26"}, | |
| 100 | + {"res/CI_MW_D.264", "289f29a103c8d95adf2909c646466904be8b06d7"}, | |
| 101 | + {"res/CVFC1_Sony_C.jsv", "4641abd7419a5580b97f16e83fd1d566339229d0"}, | |
| 102 | + {"res/CVPCMNL1_SVA_C.264", "c2b0d964de727c64b9fccb58f63b567c82bda95a"}, | |
| 103 | + {"res/LS_SVA_D.264", "72118f4d1674cf14e58bed7e67cb3aeed3df62b9"}, | |
| 104 | + {"res/MIDR_MW_D.264", "9467030f4786f75644bf06a7fc809c36d1959827"}, | |
| 105 | + {"res/MPS_MW_A.264", "67f1cfbef0e8025ed60dedccf8d9558d0636be5f"}, | |
| 106 | + {"res/MR1_BT_A.h264", "6e585f8359667a16b03e5f49a06f5ceae8d991e0"}, | |
| 107 | + {"res/MR1_MW_A.264", "d9e2bf34e9314dcc171ddaea2c5015d0421479f2"}, | |
| 108 | + {"res/MR2_MW_A.264", "628b1d4eff04c2d277f7144e23484957dad63cbe"}, | |
| 109 | + {"res/MR2_TANDBERG_E.264", "74d618bc7d9d41998edf4c85d51aa06111db6609"}, | |
| 110 | + {"res/NL1_Sony_D.jsv", "e401e30669938443c2f02522fd4d5aa1382931a0"}, | |
| 111 | + {"res/NLMQ1_JVC_C.264", "f3265c6ddf8db1b2bf604d8a2954f75532e28cda"}, | |
| 112 | + {"res/NLMQ2_JVC_C.264", "350ae86ef9ba09390d63a09b7f9ff54184109ca8"}, | |
| 113 | + {"res/NRF_MW_E.264", "20732198c04cd2591350a361e4510892f6eed3f0"}, | |
| 114 | + {"res/QCIF_2P_I_allIPCM.264", "8724c0866ebdba7ebb7209a0c0c3ae3ae38a0240"}, | |
| 115 | + {"res/SVA_BA1_B.264", "c4543b24823b16c424c673616c36c7f537089b2d"}, | |
| 116 | + {"res/SVA_BA2_D.264", "98ff2d67860462d8d8bcc9352097c06cc401d97e"}, | |
| 117 | + {"res/SVA_Base_B.264", "91f514d81cd33de9f6fbf5dbefdb189cc2e7ecf4"}, | |
| 118 | + {"res/SVA_CL1_E.264", "4fe09ab6cdc965ea10a20f1d6dd38aca954412bb"}, | |
| 119 | + {"res/SVA_FM1_E.264", "fad08c4ff7cf2307b6579853d0f4652fc26645d3"}, | |
| 120 | + {"res/SVA_NL1_B.264", "6d63f72a0c0d833b1db0ba438afff3b4180fb3e6"}, | |
| 121 | + {"res/SVA_NL2_E.264", "70453ef8097c94dd190d6d2d1d5cb83c67e66238"}, | |
| 122 | + {"res/SarVui.264", "98ff2d67860462d8d8bcc9352097c06cc401d97e"}, | |
| 123 | + {"res/Static.264", "91dd4a7a796805b2cd015cae8fd630d96c663f42"}, | |
| 124 | + {"res/Zhling_1280x720.264", "ad99f5eaa2d73ae3840e7da67313de8cfc866ce6"}, | |
| 125 | + {"res/sps_subsetsps_bothVUI.264", "d3a47032eb5dcc1963343a68e9bea12435bf1e4c"}, | |
| 126 | + {"res/test_cif_I_CABAC_PCM.264", "95fdf21470d3bbcf95505abb2164042063a79d98"}, | |
| 127 | + {"res/test_cif_I_CABAC_slice.264", "19121bc67f2b13fb8f030504fc0827e1ac6d0fdb"}, | |
| 128 | + {"res/test_cif_P_CABAC_slice.264", "521bbd0ba2422369b724c7054545cf107a56f959"}, | |
| 129 | + {"res/test_qcif_cabac.264", "587d1d05943f3cd416bf69469975fdee05361e69"}, | |
| 130 | + {"res/test_scalinglist_jm.264", "f690a3af2896a53360215fb5d35016bfd41499b3"}, | |
| 131 | + {"res/test_vd_1d.264", "5827d2338b79ff82cd091c707823e466197281d3"}, | |
| 132 | + {"res/test_vd_rc.264", "eea02e97bfec89d0418593a8abaaf55d02eaa1ca"}, | |
| 133 | + {"res/HighProfile_B_Frame_1920x1080p_30fps.h264", "50c5b8d175598c1d9e604542c4160fa1c6639adc" }, | |
| 134 | + {"res/HighProfile_B_Frame_1920x1080p_2397fps.h264", "16967cc21b6853b651cfd0a1a858eeec8565836a" }, | |
| 135 | +}; | |
| 136 | + | |
| 137 | +INSTANTIATE_TEST_CASE_P (DecodeFile, DecoderOutputTest, | |
| 138 | + ::testing::ValuesIn (kFileParamArray)); | |