shithub: openh264

Download patch

ref: f78f39568348aa806fc9623b5b7e07dd606fd6c3
parent: a22d976b4e823d3f3cb26f1b8dd433116c156700
author: syureyi <[email protected]>
date: Fri Jul 25 10:05:36 EDT 2014

checking the scripits for unittest automatically on mobile

--- a/test/api/DataGenerator.cpp
+++ b/test/api/DataGenerator.cpp
@@ -22,8 +22,12 @@
   }
 
   FileInputStream fileStream;
-  if (!fileStream.Open ("res/CiscoVT2people_160x96_6fps.yuv")) {
-    return false;
+ #if defined(ANDROID_NDK)
+  if (!fileStream.Open ("/sdcard/res/CiscoVT2people_160x96_6fps.yuv")) {
+#else
+ if (!fileStream.Open ("res/CiscoVT2people_160x96_6fps.yuv")) {
+#endif    
+return false;
   }
   if (fileStream.read (sBuf.data(), kiFrameSize) == kiFrameSize) {
     int32_t iStartPosX = rand() % (SRC_FRAME_WIDTH - iWidth);
--- a/test/api/decode_encode_test.cpp
+++ b/test/api/decode_encode_test.cpp
@@ -102,11 +102,18 @@
     CompareHash (digest, p.hashStr);
   }
 }
-
+#if defined(ANDROID_NDK)
 static const DecodeEncodeFileParam kFileParamArray[] = {
+  {"/sdcard/res/test_vd_1d.264", "a4c7299ec1a7bacd5819685e221a79ac2b56cdbc", 320, 192, 12.0f},
+  {"/sdcard/res/test_vd_rc.264", "106fd8cc978c1801b0d1f8297e9b7f17d5336e15", 320, 192, 12.0f},
+};
+#else
+static const DecodeEncodeFileParam kFileParamArray[] = {
   {"res/test_vd_1d.264", "a4c7299ec1a7bacd5819685e221a79ac2b56cdbc", 320, 192, 12.0f},
   {"res/test_vd_rc.264", "106fd8cc978c1801b0d1f8297e9b7f17d5336e15", 320, 192, 12.0f},
 };
+
+#endif
 
 INSTANTIATE_TEST_CASE_P (DecodeEncodeFile, DecodeEncodeTest,
                          ::testing::ValuesIn (kFileParamArray));
--- a/test/api/decoder_test.cpp
+++ b/test/api/decoder_test.cpp
@@ -60,8 +60,44 @@
     CompareHash (digest, p.hashStr);
   }
 }
+#if defined(ANDROID_NDK)
 
 static const FileParam kFileParamArray[] = {
+  {"/sdcard/res/test_vd_1d.264", "5827d2338b79ff82cd091c707823e466197281d3"},
+  {"/sdcard/res/test_vd_rc.264", "eea02e97bfec89d0418593a8abaaf55d02eaa1ca"},
+  {"/sdcard/res/Static.264", "91dd4a7a796805b2cd015cae8fd630d96c663f42"},
+  {"/sdcard/res/BA1_FT_C.264", "418d152fb85709b6f172799dcb239038df437cfa"},
+  {"/sdcard/res/BA1_Sony_D.jsv", "d94b5ceed5686a03ea682b53d415dee999d27eb6"},
+  {"/sdcard/res/BAMQ1_JVC_C.264", "613cf662c23e5d9e1d7da7fe880a3c427411d171"},
+  {"/sdcard/res/BAMQ2_JVC_C.264", "11bcf3713f520e606a8326d37e00e5fd6c9fd4a0"},
+  {"/sdcard/res/BA_MW_D.264", "afd7a9765961ca241bb4bdf344b31397bec7465a"},
+  {"/sdcard/res/BANM_MW_D.264", "92d924a857a1a7d7d9b224eaa3887830f15dee7f"},
+  {"/sdcard/res/BASQP1_Sony_C.jsv", "3986c8c9d2876d2f0748b925101b152c6ec8b811"},
+  {"/sdcard/res/CI1_FT_B.264", "cbfec15e17a504678b19a1191992131c92a1ac26"},
+  {"/sdcard/res/CI_MW_D.264", "289f29a103c8d95adf2909c646466904be8b06d7"},
+  {"/sdcard/res/CVFC1_Sony_C.jsv", "4641abd7419a5580b97f16e83fd1d566339229d0"},
+  {"/sdcard/res/CVPCMNL1_SVA_C.264", "c2b0d964de727c64b9fccb58f63b567c82bda95a"},
+  {"/sdcard/res/LS_SVA_D.264", "72118f4d1674cf14e58bed7e67cb3aeed3df62b9"},
+  {"/sdcard/res/MIDR_MW_D.264", "9467030f4786f75644bf06a7fc809c36d1959827"},
+  {"/sdcard/res/MPS_MW_A.264", "67f1cfbef0e8025ed60dedccf8d9558d0636be5f"},
+  {"/sdcard/res/MR1_BT_A.h264", "6e585f8359667a16b03e5f49a06f5ceae8d991e0"},
+  {"/sdcard/res/MR1_MW_A.264", "d9e2bf34e9314dcc171ddaea2c5015d0421479f2"},
+  {"/sdcard/res/MR2_MW_A.264", "628b1d4eff04c2d277f7144e23484957dad63cbe"},
+  {"/sdcard/res/MR2_TANDBERG_E.264", "74d618bc7d9d41998edf4c85d51aa06111db6609"},
+  {"/sdcard/res/NL1_Sony_D.jsv", "e401e30669938443c2f02522fd4d5aa1382931a0"},
+  {"/sdcard/res/NLMQ1_JVC_C.264", "f3265c6ddf8db1b2bf604d8a2954f75532e28cda"},
+  {"/sdcard/res/NLMQ2_JVC_C.264", "350ae86ef9ba09390d63a09b7f9ff54184109ca8"},
+  {"/sdcard/res/NRF_MW_E.264", "20732198c04cd2591350a361e4510892f6eed3f0"},
+  {"/sdcard/res/SVA_BA1_B.264", "c4543b24823b16c424c673616c36c7f537089b2d"},
+  {"/sdcard/res/SVA_BA2_D.264", "98ff2d67860462d8d8bcc9352097c06cc401d97e"},
+  {"/sdcard/res/SVA_Base_B.264", "91f514d81cd33de9f6fbf5dbefdb189cc2e7ecf4"},
+  {"/sdcard/res/SVA_CL1_E.264", "4fe09ab6cdc965ea10a20f1d6dd38aca954412bb"},
+  {"/sdcard/res/SVA_FM1_E.264", "fad08c4ff7cf2307b6579853d0f4652fc26645d3"},
+  {"/sdcard/res/SVA_NL1_B.264", "6d63f72a0c0d833b1db0ba438afff3b4180fb3e6"},
+  {"/sdcard/res/SVA_NL2_E.264", "70453ef8097c94dd190d6d2d1d5cb83c67e66238"}
+};
+#else
+static const FileParam kFileParamArray[] = {
   {"res/test_vd_1d.264", "5827d2338b79ff82cd091c707823e466197281d3"},
   {"res/test_vd_rc.264", "eea02e97bfec89d0418593a8abaaf55d02eaa1ca"},
   {"res/Static.264", "91dd4a7a796805b2cd015cae8fd630d96c663f42"},
@@ -75,26 +111,27 @@
   {"res/CI1_FT_B.264", "cbfec15e17a504678b19a1191992131c92a1ac26"},
   {"res/CI_MW_D.264", "289f29a103c8d95adf2909c646466904be8b06d7"},
   {"res/CVFC1_Sony_C.jsv", "4641abd7419a5580b97f16e83fd1d566339229d0"},
-  {"res/CVPCMNL1_SVA_C.264", "c2b0d964de727c64b9fccb58f63b567c82bda95a"},
-  {"res/LS_SVA_D.264", "72118f4d1674cf14e58bed7e67cb3aeed3df62b9"},
-  {"res/MIDR_MW_D.264", "9467030f4786f75644bf06a7fc809c36d1959827"},
-  {"res/MPS_MW_A.264", "67f1cfbef0e8025ed60dedccf8d9558d0636be5f"},
-  {"res/MR1_BT_A.h264", "6e585f8359667a16b03e5f49a06f5ceae8d991e0"},
-  {"res/MR1_MW_A.264", "d9e2bf34e9314dcc171ddaea2c5015d0421479f2"},
-  {"res/MR2_MW_A.264", "628b1d4eff04c2d277f7144e23484957dad63cbe"},
-  {"res/MR2_TANDBERG_E.264", "74d618bc7d9d41998edf4c85d51aa06111db6609"},
-  {"res/NL1_Sony_D.jsv", "e401e30669938443c2f02522fd4d5aa1382931a0"},
-  {"res/NLMQ1_JVC_C.264", "f3265c6ddf8db1b2bf604d8a2954f75532e28cda"},
-  {"res/NLMQ2_JVC_C.264", "350ae86ef9ba09390d63a09b7f9ff54184109ca8"},
-  {"res/NRF_MW_E.264", "20732198c04cd2591350a361e4510892f6eed3f0"},
-  {"res/SVA_BA1_B.264", "c4543b24823b16c424c673616c36c7f537089b2d"},
-  {"res/SVA_BA2_D.264", "98ff2d67860462d8d8bcc9352097c06cc401d97e"},
-  {"res/SVA_Base_B.264", "91f514d81cd33de9f6fbf5dbefdb189cc2e7ecf4"},
-  {"res/SVA_CL1_E.264", "4fe09ab6cdc965ea10a20f1d6dd38aca954412bb"},
-  {"res/SVA_FM1_E.264", "fad08c4ff7cf2307b6579853d0f4652fc26645d3"},
-  {"res/SVA_NL1_B.264", "6d63f72a0c0d833b1db0ba438afff3b4180fb3e6"},
-  {"res/SVA_NL2_E.264", "70453ef8097c94dd190d6d2d1d5cb83c67e66238"}
+  {"res/CVPCMNL1_SVA_C.264", "c2b0d964de727c64b9fccb58f63b567c82bda95a"},   
+  {"res/LS_SVA_D.264", "72118f4d1674cf14e58bed7e67cb3aeed3df62b9"},         
+  {"res/MIDR_MW_D.264", "9467030f4786f75644bf06a7fc809c36d1959827"},        
+  {"res/MPS_MW_A.264", "67f1cfbef0e8025ed60dedccf8d9558d0636be5f"},         
+  {"res/MR1_BT_A.h264", "6e585f8359667a16b03e5f49a06f5ceae8d991e0"},        
+  {"res/MR1_MW_A.264", "d9e2bf34e9314dcc171ddaea2c5015d0421479f2"},         
+  {"res/MR2_MW_A.264", "628b1d4eff04c2d277f7144e23484957dad63cbe"},         
+  {"res/MR2_TANDBERG_E.264", "74d618bc7d9d41998edf4c85d51aa06111db6609"},   
+  {"res/NL1_Sony_D.jsv", "e401e30669938443c2f02522fd4d5aa1382931a0"},       
+  {"res/NLMQ1_JVC_C.264", "f3265c6ddf8db1b2bf604d8a2954f75532e28cda"},      
+  {"res/NLMQ2_JVC_C.264", "350ae86ef9ba09390d63a09b7f9ff54184109ca8"},      
+  {"res/NRF_MW_E.264", "20732198c04cd2591350a361e4510892f6eed3f0"},         
+  {"res/SVA_BA1_B.264", "c4543b24823b16c424c673616c36c7f537089b2d"},        
+  {"res/SVA_BA2_D.264", "98ff2d67860462d8d8bcc9352097c06cc401d97e"},        
+  {"res/SVA_Base_B.264", "91f514d81cd33de9f6fbf5dbefdb189cc2e7ecf4"},       
+  {"res/SVA_CL1_E.264", "4fe09ab6cdc965ea10a20f1d6dd38aca954412bb"},        
+  {"res/SVA_FM1_E.264", "fad08c4ff7cf2307b6579853d0f4652fc26645d3"},        
+  {"res/SVA_NL1_B.264", "6d63f72a0c0d833b1db0ba438afff3b4180fb3e6"},        
+  {"res/SVA_NL2_E.264", "70453ef8097c94dd190d6d2d1d5cb83c67e66238"}         
 };
 
+#endif
 INSTANTIATE_TEST_CASE_P (DecodeFile, DecoderOutputTest,
                          ::testing::ValuesIn (kFileParamArray));
--- a/test/api/encoder_test.cpp
+++ b/test/api/encoder_test.cpp
@@ -67,9 +67,60 @@
     CompareHash (digest, p.hashStr);
   }
 }
-
+#if defined(ANDROID_NDK)
 static const EncodeFileParam kFileParamArray[] = {
   {
+    "/sdcard/res/CiscoVT2people_320x192_12fps.yuv",
+    "0a36b75e423fc6b49f6adf7eee12c039a096f538", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1
+  },
+  {
+    "/sdcard/res/CiscoVT2people_160x96_6fps.yuv",
+    "73981e6ea5b62f7338212c538a7cc755e7c9c030", CAMERA_VIDEO_REAL_TIME, 160, 96, 6.0f, SM_SINGLE_SLICE, false, 1
+  },
+  {
+    "/sdcard/res/Static_152_100.yuv",
+    "02bbff550ee0630e44e46e14dc459d3686f2a360", CAMERA_VIDEO_REAL_TIME, 152, 100, 6.0f, SM_SINGLE_SLICE, false, 1
+  },
+  {
+    "/sdcard/res/CiscoVT2people_320x192_12fps.yuv",
+    "c8b759bcec7ffa048f1d3ded594b8815bed0aead", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_ROWMB_SLICE, false, 1 // One slice per MB row
+  },
+  {
+    "/sdcard/res/CiscoVT2people_320x192_12fps.yuv",
+    "e64ba75456c821ca35a949eda89f85bff8ee69fa", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, true, 1
+  },
+  {
+    "/sdcard/res/CiscoVT2people_320x192_12fps.yuv",
+    "684e6d141ada776892bdb01ee93efe475983ed36", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 2
+  },
+  {
+    "/sdcard/res/Cisco_Absolute_Power_1280x720_30fps.yuv",
+    "2bc06262d87fa0897ad4c336cc4047d5a67f7203", CAMERA_VIDEO_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1
+  },
+  {
+    "/sdcard/res/Cisco_Absolute_Power_1280x720_30fps.yuv",
+    "68c3220e49b7a57d563faf7c99a870ab34a23400", CAMERA_VIDEO_REAL_TIME, 1280, 720, 30.0f, SM_SINGLE_SLICE, false, 4
+  },
+  {
+    "/sdcard/res/CiscoVT2people_320x192_12fps.yuv",
+    "030d0e2d742ac039c2ab6333fe7cb18623c0d283", SCREEN_CONTENT_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1
+  },
+  {
+    "/sdcard/res/CiscoVT2people_160x96_6fps.yuv",
+    "40aa19d4b2684a59e689860d2a793876f33904f7", SCREEN_CONTENT_REAL_TIME, 160, 96, 6.0f, SM_SINGLE_SLICE, false, 1
+  },
+  {
+    "/sdcard/res/Static_152_100.yuv",
+    "494068b59aa9ed9118a9f33174b732024effc870", SCREEN_CONTENT_REAL_TIME, 152, 100, 6.0f, SM_SINGLE_SLICE, false, 1
+  },
+  {
+    "/sdcard/res/Cisco_Absolute_Power_1280x720_30fps.yuv",
+    "dc5aedee4d8f1fe8d6647a9f7b8c2d3df758ac27", SCREEN_CONTENT_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1
+  },
+};
+#else
+static const EncodeFileParam kFileParamArray[] = {
+  {
     "res/CiscoVT2people_320x192_12fps.yuv",
     "0a36b75e423fc6b49f6adf7eee12c039a096f538", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1
   },
@@ -119,5 +170,6 @@
   },
 };
 
+#endif
 INSTANTIATE_TEST_CASE_P (EncodeFile, EncoderOutputTest,
                          ::testing::ValuesIn (kFileParamArray));
--- a/test/build/android/src/com/cisco/codec/unittest/MainActivity.java
+++ b/test/build/android/src/com/cisco/codec/unittest/MainActivity.java
@@ -28,6 +28,8 @@
 	@Override
 	public void onDestroy()
 	{
+        super.onDestroy();
+        Log.i("codec_unittest","OnDestroy");
 		Process.killProcess(Process.myPid());
 	}
 
@@ -55,7 +57,6 @@
 				Log.i("codec_unittest","codec unittest runing @"+path);
 				DoUnittest("/sdcard", path);
 				Log.i("codec_unittest","codec unittest end");
-				Process.killProcess(Process.myPid());
 				finish();
 			}
 
--- a/test/build/ios/codec_unittest/codec_unittest/main.m
+++ b/test/build/ios/codec_unittest/codec_unittest/main.m
@@ -13,7 +13,7 @@
 extern int CodecUtMain(int argc, char** argv);
 
 
-int GetDocumentPath(char *pPath, unsigned long *pLen)
+int DoTest(char *pPath, unsigned long *pLen)
 {
     if (!pLen) return 1;
     unsigned long uPathLen = *pLen;
@@ -27,10 +27,17 @@
         return 2;
     }
     NSString* document = [paths objectAtIndex:0];
+    NSFileManager* manager = [NSFileManager defaultManager];
+    [manager changeCurrentDirectoryPath:[document stringByExpandingTildeInPath]];
     NSString* escapedPath = [document stringByReplacingOccurrencesOfString:@" " withString:@"\\ "];
     unsigned long uDocumentPathLen = [escapedPath length];
     uPathLen= (uDocumentPathLen <= uPathLen) ? uDocumentPathLen : uPathLen;
     memcpy(pPath,[escapedPath UTF8String],uPathLen);
+    char path[1024] = "";
+    sprintf(path, "%s%s",pPath,"/codec_unittest.xml");
+    int argc =2;
+    char* argv[]={(char*)"codec_unittest",path};
+    CodecUtMain(argc,argv);
     return 0;
 }
 
@@ -42,18 +49,22 @@
     //Call the UT
 #ifdef IOS_SIMULATOR
     const char* path="/tmp/codec_unittest.xml";
-#else
-    char xmlWritePath[1024] = "";
-    unsigned long uPathLen = 1024;
-    char path[1024] = "";
-    GetDocumentPath(xmlWritePath,&uPathLen);
-    sprintf(path, "%s%s",xmlWritePath,"/codec_unittest.xml");
-#endif
     argc =2;
     argv[0]=(char*)"codec_unittest";
     argv[1]=path;
     CodecUtMain(argc,argv);
     abort();
+#else
+    char xmlWritePath[1024] = "";
+    unsigned long uPathLen = 1024;
+    if(DoTest(xmlWritePath,&uPathLen) == 0)
+        NSLog(@"Unit test running sucessfully on devices");
+    else
+        NSLog(@"Unit test runing failed on devices");
+    abort();
+    
+#endif
+    
     @autoreleasepool {
         return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
     }