Showing the changes to test/api/decoder_test.cpp (1 of 23 files). Show all
Unified · Split
| @@ -0,0 +1,100 @@ | ||
| 1 | +#include <gtest/gtest.h> | |
| 2 | +#include "utils/HashFunctions.h" | |
| 3 | +#include "BaseDecoderTest.h" | |
| 4 | + | |
| 5 | +static void UpdateHashFromPlane(SHA1Context* ctx, const uint8_t* plane, | |
| 6 | + int width, int height, int stride) { | |
| 7 | + for (int i = 0; i < height; i++) { | |
| 8 | + SHA1Input(ctx, plane, width); | |
| 9 | + plane += stride; | |
| 10 | + } | |
| 11 | +} | |
| 12 | + | |
| 13 | + | |
| 14 | +class DecoderInitTest : public ::testing::Test, public BaseDecoderTest { | |
| 15 | + public: | |
| 16 | + virtual void SetUp() { | |
| 17 | + BaseDecoderTest::SetUp(); | |
| 18 | + } | |
| 19 | + virtual void TearDown() { | |
| 20 | + BaseDecoderTest::TearDown(); | |
| 21 | + } | |
| 22 | +}; | |
| 23 | + | |
| 24 | +TEST_F(DecoderInitTest, JustInit) {} | |
| 25 | + | |
| 26 | +struct FileParam { | |
| 27 | + const char* fileName; | |
| 28 | + const char* hashStr; | |
| 29 | +}; | |
| 30 | + | |
| 31 | +class DecoderOutputTest : public ::testing::WithParamInterface<FileParam>, | |
| 32 | + public DecoderInitTest, public BaseDecoderTest::Callback { | |
| 33 | + public: | |
| 34 | + virtual void SetUp() { | |
| 35 | + DecoderInitTest::SetUp(); | |
| 36 | + if (HasFatalFailure()) { | |
| 37 | + return; | |
| 38 | + } | |
| 39 | + SHA1Reset(&ctx_); | |
| 40 | + } | |
| 41 | + virtual void onDecodeFrame(const Frame& frame) { | |
| 42 | + const Plane& y = frame.y; | |
| 43 | + const Plane& u = frame.u; | |
| 44 | + const Plane& v = frame.v; | |
| 45 | + UpdateHashFromPlane(&ctx_, y.data, y.width, y.height, y.stride); | |
| 46 | + UpdateHashFromPlane(&ctx_, u.data, u.width, u.height, u.stride); | |
| 47 | + UpdateHashFromPlane(&ctx_, v.data, v.width, v.height, v.stride); | |
| 48 | + } | |
| 49 | + protected: | |
| 50 | + SHA1Context ctx_; | |
| 51 | +}; | |
| 52 | + | |
| 53 | +TEST_P(DecoderOutputTest, CompareOutput) { | |
| 54 | + FileParam p = GetParam(); | |
| 55 | + DecodeFile(p.fileName, this); | |
| 56 | + | |
| 57 | + unsigned char digest[SHA_DIGEST_LENGTH]; | |
| 58 | + SHA1Result(&ctx_, digest); | |
| 59 | + if (!HasFatalFailure()) { | |
| 60 | + CompareHash(digest, p.hashStr); | |
| 61 | + } | |
| 62 | +} | |
| 63 | + | |
| 64 | +static const FileParam kFileParamArray[] = { | |
| 65 | + {"res/test_vd_1d.264", "5827d2338b79ff82cd091c707823e466197281d3"}, | |
| 66 | + {"res/test_vd_rc.264", "eea02e97bfec89d0418593a8abaaf55d02eaa1ca"}, | |
| 67 | + {"res/Static.264", "91dd4a7a796805b2cd015cae8fd630d96c663f42"}, | |
| 68 | + {"res/BA1_FT_C.264", "418d152fb85709b6f172799dcb239038df437cfa"}, | |
| 69 | + {"res/BA1_Sony_D.jsv", "d94b5ceed5686a03ea682b53d415dee999d27eb6"}, | |
| 70 | + {"res/BAMQ1_JVC_C.264", "613cf662c23e5d9e1d7da7fe880a3c427411d171"}, | |
| 71 | + {"res/BAMQ2_JVC_C.264", "11bcf3713f520e606a8326d37e00e5fd6c9fd4a0"}, | |
| 72 | + {"res/BA_MW_D.264", "afd7a9765961ca241bb4bdf344b31397bec7465a"}, | |
| 73 | + {"res/BANM_MW_D.264", "92d924a857a1a7d7d9b224eaa3887830f15dee7f"}, | |
| 74 | + {"res/BASQP1_Sony_C.jsv", "3986c8c9d2876d2f0748b925101b152c6ec8b811"}, | |
| 75 | + {"res/CI1_FT_B.264", "cbfec15e17a504678b19a1191992131c92a1ac26"}, | |
| 76 | + {"res/CI_MW_D.264", "289f29a103c8d95adf2909c646466904be8b06d7"}, | |
| 77 | + {"res/CVFC1_Sony_C.jsv", "4641abd7419a5580b97f16e83fd1d566339229d0"}, | |
| 78 | + {"res/CVPCMNL1_SVA_C.264", "c2b0d964de727c64b9fccb58f63b567c82bda95a"}, | |
| 79 | + {"res/LS_SVA_D.264", "72118f4d1674cf14e58bed7e67cb3aeed3df62b9"}, | |
| 80 | + {"res/MIDR_MW_D.264", "9467030f4786f75644bf06a7fc809c36d1959827"}, | |
| 81 | + {"res/MPS_MW_A.264", "67f1cfbef0e8025ed60dedccf8d9558d0636be5f"}, | |
| 82 | + {"res/MR1_BT_A.h264", "6e585f8359667a16b03e5f49a06f5ceae8d991e0"}, | |
| 83 | + {"res/MR1_MW_A.264", "d9e2bf34e9314dcc171ddaea2c5015d0421479f2"}, | |
| 84 | + {"res/MR2_MW_A.264", "628b1d4eff04c2d277f7144e23484957dad63cbe"}, | |
| 85 | + {"res/MR2_TANDBERG_E.264", "74d618bc7d9d41998edf4c85d51aa06111db6609"}, | |
| 86 | + {"res/NL1_Sony_D.jsv", "e401e30669938443c2f02522fd4d5aa1382931a0"}, | |
| 87 | + {"res/NLMQ1_JVC_C.264", "f3265c6ddf8db1b2bf604d8a2954f75532e28cda"}, | |
| 88 | + {"res/NLMQ2_JVC_C.264", "350ae86ef9ba09390d63a09b7f9ff54184109ca8"}, | |
| 89 | + {"res/NRF_MW_E.264", "20732198c04cd2591350a361e4510892f6eed3f0"}, | |
| 90 | + {"res/SVA_BA1_B.264", "c4543b24823b16c424c673616c36c7f537089b2d"}, | |
| 91 | + {"res/SVA_BA2_D.264", "98ff2d67860462d8d8bcc9352097c06cc401d97e"}, | |
| 92 | + {"res/SVA_Base_B.264", "91f514d81cd33de9f6fbf5dbefdb189cc2e7ecf4"}, | |
| 93 | + {"res/SVA_CL1_E.264", "4fe09ab6cdc965ea10a20f1d6dd38aca954412bb"}, | |
| 94 | + {"res/SVA_FM1_E.264", "fad08c4ff7cf2307b6579853d0f4652fc26645d3"}, | |
| 95 | + {"res/SVA_NL1_B.264", "6d63f72a0c0d833b1db0ba438afff3b4180fb3e6"}, | |
| 96 | + {"res/SVA_NL2_E.264", "70453ef8097c94dd190d6d2d1d5cb83c67e66238"} | |
| 97 | +}; | |
| 98 | + | |
| 99 | +INSTANTIATE_TEST_CASE_P(DecodeFile, DecoderOutputTest, | |
| 100 | + ::testing::ValuesIn(kFileParamArray)); | |