• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <gtest/gtest.h>
2 #include "utils/HashFunctions.h"
3 #include "BaseThreadDecoderTest.h"
4 #include <string>
5 
UpdateHashFromPlane(SHA1Context * ctx,const uint8_t * plane,int width,int height,int stride)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 ThreadDecoderCapabilityTest : public ::testing::Test {
15  public:
SetUp()16   virtual void SetUp() {}
TearDown()17   virtual void TearDown() {}
18 };
19 
TEST_F(ThreadDecoderCapabilityTest,JustInit)20 TEST_F (ThreadDecoderCapabilityTest, 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 ThreadDecoderInitTest : public ::testing::Test, public BaseThreadDecoderTest {
37  public:
SetUp()38   virtual void SetUp() {
39     BaseThreadDecoderTest::SetUp();
40   }
TearDown()41   virtual void TearDown() {
42     BaseThreadDecoderTest::TearDown();
43   }
44 };
45 
TEST_F(ThreadDecoderInitTest,JustInit)46 TEST_F (ThreadDecoderInitTest, JustInit) {}
47 struct FileParam {
48   const char* fileName;
49   const char* hashStr;
50 };
51 
52 class ThreadDecoderOutputTest : public ::testing::WithParamInterface<FileParam>,
53   public ThreadDecoderInitTest, public BaseThreadDecoderTest::Callback {
54  public:
SetUp()55   virtual void SetUp() {
56     ThreadDecoderInitTest::SetUp();
57     if (HasFatalFailure()) {
58       return;
59     }
60     SHA1Reset (&ctx_);
61   }
onDecodeFrame(const Frame & frame)62   virtual void onDecodeFrame (const Frame& frame) {
63     const Plane& y = frame.y;
64     const Plane& u = frame.u;
65     const Plane& v = frame.v;
66     UpdateHashFromPlane (&ctx_, y.data, y.width, y.height, y.stride);
67     UpdateHashFromPlane (&ctx_, u.data, u.width, u.height, u.stride);
68     UpdateHashFromPlane (&ctx_, v.data, v.width, v.height, v.stride);
69   }
70  protected:
71   SHA1Context ctx_;
72 };
73 
TEST_P(ThreadDecoderOutputTest,CompareOutput)74 TEST_P (ThreadDecoderOutputTest, CompareOutput) {
75   FileParam p = GetParam();
76 #if defined(ANDROID_NDK)
77   std::string filename = std::string ("/sdcard/") + p.fileName;
78   ASSERT_TRUE (ThreadDecodeFile (filename.c_str(), this));
79 #else
80   ASSERT_TRUE (ThreadDecodeFile (p.fileName, this));
81 #endif
82 
83   unsigned char digest[SHA_DIGEST_LENGTH];
84   SHA1Result (&ctx_, digest);
85   if (!HasFatalFailure()) {
86     std::string p_hashStr (p.hashStr);
87     std::stringstream ss (p_hashStr);
88     std::string buf[4];
89     const char* hashStr[4];
90     int i = 0;
91     while (i < 4 && ss >> buf[i]) {
92       hashStr[i] = buf[i].c_str();
93       ++i;
94     }
95     CompareHashAnyOf (digest, hashStr, i);
96   }
97 }
98 static const FileParam kFileParamArray[] = {
99   {"res/Adobe_PDF_sample_a_1024x768_50Frms.264", "041434a5819d1d903d49c0eda884b345e9f83596"},
100   //{"res/BA1_FT_C.264", "072ccfd92528f09ae8888cb5e023af511e1010a1"}, //multi hash values only in travis-ci build machine
101   {"res/BA1_Sony_D.jsv", "37c9a951a0348d6abe1880b59e2b5a4d7d18c94c"},
102   {"res/BAMQ1_JVC_C.264", "6720462624f632f5475716ef32a7bbd12b3b428a"},
103   {"res/BAMQ2_JVC_C.264", "5f0fbb0dab7961e782224f6887c83d4866fc1af8"},
104   {"res/BA_MW_D.264", "ace02cdce720bdb0698b40dc749a0e61fe0f590b"},
105   //{"res/BANM_MW_D.264", "c51f1d2fa63dba4f5787f1b726c056d1c01d6ab9"}, //multi hash values only in travis-ci build machine
106   {"res/BASQP1_Sony_C.jsv", "2e10e98fc54f92cb5e72513bf417c4e4df333361"},
107   //{"res/CI1_FT_B.264", "721e555a33cfff81b6034a127334c5891776373c"}, //multi hash values only in travis-ci build machine
108   {"res/CI_MW_D.264", "49a8916edd3e571efad328f2784fbe6aec5570d7"},
109   {"res/CVFC1_Sony_C.jsv", "5cc447bb7906d5b9858cc7092aaf491035861660"},
110   {"res/CVPCMNL1_SVA_C.264", "c2b0d964de727c64b9fccb58f63b567c82bda95a"},
111   //{"res/LS_SVA_D.264", "e020a1c6668501887bb55e00741ebfdbc91d400d"}, //Multi-thread decoding hanging due to high pSps->iNumRefFrames which is 15
112   {"res/MIDR_MW_D.264", "aeded2be7b97484cbf25f367ec34208f2220a8ab"},
113   {"res/MPS_MW_A.264", "b0fce28218e678d89f464810f88b143ada49dd06"},
114   //{"res/MR1_BT_A.h264", "7f6d806f12d19ec991182467e801a78fb4f80e04"}, //multi hash values only in travis-ci build machine
115   //{"res/MR1_MW_A.264", "14d8ddb12ed711444039329db29c496b079680ba"}, //multi hash values on osx x86_64 and segment fault on Linux m32 only in travis-ci build machine
116   //{"res/MR2_MW_A.264", "6d332a653fe3b923eb3af8f3695d46ce2a1d4b2c"}, //multi hash values
117   //{"res/MR2_TANDBERG_E.264", "74d618bc7d9d41998edf4c85d51aa06111db6609"}, //Multi-thread decoding hanging due to high pSps->iNumRefFrames which is 15
118   {"res/NL1_Sony_D.jsv", "e401e30669938443c2f02522fd4d5aa1382931a0"},
119   {"res/NLMQ1_JVC_C.264", "f3265c6ddf8db1b2bf604d8a2954f75532e28cda"},
120   {"res/NLMQ2_JVC_C.264", "350ae86ef9ba09390d63a09b7f9ff54184109ca8"},
121   {"res/NRF_MW_E.264", "866f267afd2ed1595bcb90de0f539e929c169aa4"},
122   {"res/QCIF_2P_I_allIPCM.264", "9879ce127d3263cfbaf5211ab6657dbf0ccabea8"},
123   { "res/SVA_BA1_B.264", "4cb45a99ae44a0a98b174efd66245daa1fbaeb47"},
124   {"res/SVA_BA2_D.264", "ac9e960015b96f83279840802f6637c61ee1c5b8"},
125   {"res/SVA_Base_B.264", "e6010d1b47aa796c1f5295b2563ed696aa9c37ab"},
126   {"res/SVA_CL1_E.264", "4fe09ab6cdc965ea10a20f1d6dd38aca954412bb"},
127   {"res/SVA_FM1_E.264", "1a114fbd096f637acd0c3fb8f35bdfa3bc275199"},
128   {"res/SVA_NL1_B.264", "6d63f72a0c0d833b1db0ba438afff3b4180fb3e6"},
129   {"res/SVA_NL2_E.264", "70453ef8097c94dd190d6d2d1d5cb83c67e66238"},
130   {"res/SarVui.264", "ac9e960015b96f83279840802f6637c61ee1c5b8"},
131   {"res/Static.264", "1310f9a1d7d115eec8155d071b9b45b5cfbf8321"},
132   {"res/Zhling_1280x720.264", "10f9c803e80b51786f7833255afc3ef75c5c1339"},
133   {"res/sps_subsetsps_bothVUI.264", "d65a34075c452196401340c554e83225c9454397"},
134   //{"res/test_cif_I_CABAC_PCM.264", "95fdf21470d3bbcf95505abb2164042063a79d98"}, //multi hash values only in travis-ci build machine
135   //{"res/test_cif_I_CABAC_slice.264", "a7154eb1d0909eb9fd1e4e89f5d6271e5201814b"}, //multi hash values only in travis-ci build machine
136   //{"res/test_cif_P_CABAC_slice.264", "b08bcf1056458ae113d0a55f35e6b00eb2bd7811"},//multi hash values only in travis-ci build machine
137   {"res/test_qcif_cabac.264", "c79e9a32e4d9e38a1bd12079da19dcb0d2efe539"},
138   {"res/test_scalinglist_jm.264", "b36efd05c8b17faa23f1c071b92aa5d55a5a826f"},
139   {"res/test_vd_1d.264", "15d8beaf991f9e5d56a854cdafc0a7abdd5bec69"},
140   {"res/test_vd_rc.264", "cd6ef57fc884e5ecd9867591b01e35e3f091b8d0"},
141   {"res/Cisco_Men_whisper_640x320_CABAC_Bframe_9.264", "5d3d08fb47ac8c6e379c1572aed517522d883920"},
142   {"res/Cisco_Men_whisper_640x320_CAVLC_Bframe_9.264", "89742b454cac4843e0bf18a3df9b46f21155b48a"},
143   {"res/Cisco_Adobe_PDF_sample_a_1024x768_CAVLC_Bframe_9.264", "5fce0b92c5f2a1636ea06ae48ea208908fd01416"},
144   {"res/VID_1280x544_cabac_temporal_direct.264", "ae5f21eff917d09d5a1ba2ad2075edd92eb6b61c"},
145   //{"res/VID_1280x720_cabac_temporal_direct.264", "2597181429a48740a143053a5b027dcbe4173f4e"}, // hangs only on travis - ci build machine
146   {"res/VID_1920x1080_cabac_temporal_direct.264", "8c93ae9acfdf6d902c1a47102d4bf3294f45c0f3"},
147   {"res/VID_1280x544_cavlc_temporal_direct.264", "d9b31a2586ee156fe697de5934afb5a769f79494"},
148   {"res/VID_1280x720_cavlc_temporal_direct.264", "888c31cef73eb6804e2469fa77e51636c915ff82"},
149   {"res/VID_1920x1080_cavlc_temporal_direct.264", "4467039825f472bae31e58b383b1f2c9a73ce8e0"},
150 };
151 
152 INSTANTIATE_TEST_CASE_P (ThreadDecodeFile, ThreadDecoderOutputTest,
153                          ::testing::ValuesIn (kFileParamArray));
154