Fixed MediaSDK tests and build warnings
authorMaksim Shabunin <maksim.shabunin@gmail.com>
Wed, 30 Aug 2017 15:08:36 +0000 (18:08 +0300)
committerMaksim Shabunin <maksim.shabunin@gmail.com>
Thu, 31 Aug 2017 13:50:42 +0000 (16:50 +0300)
modules/videoio/src/cap_mfx_common.hpp
modules/videoio/src/cap_mfx_writer.cpp
modules/videoio/test/test_mfx.cpp

index aea0164..1e97849 100644 (file)
@@ -156,16 +156,6 @@ inline std::ostream & operator<<(std::ostream &out, const mfxFrameData &data) {
 
 //==================================================================================================
 
-static const int CC_MPG2 = FourCC('M', 'P', 'G', '2').vali32;
-static const int CC_H264 = FourCC('H', '2', '6', '4').vali32;
-static const int CC_X264 = FourCC('X', '2', '6', '4').vali32;
-static const int CC_AVC  = FourCC('A', 'V', 'C', ' ').vali32;
-static const int CC_H265 = FourCC('H', '2', '6', '5').vali32;
-static const int CC_HEVC = FourCC('H', 'E', 'V', 'C').vali32;
-static const int CC_VC1  = FourCC('V', 'C', '1', ' ').vali32;
-
-//==================================================================================================
-
 template <typename T>
 inline void cleanup(T * &ptr)
 {
index 9fc0063..6f8700a 100644 (file)
@@ -11,6 +11,13 @@ using namespace cv;
 
 inline mfxU32 codecIdByFourCC(int fourcc)
 {
+    const int CC_MPG2 = FourCC('M', 'P', 'G', '2').vali32;
+    const int CC_H264 = FourCC('H', '2', '6', '4').vali32;
+    const int CC_X264 = FourCC('X', '2', '6', '4').vali32;
+    const int CC_AVC = FourCC('A', 'V', 'C', ' ').vali32;
+    const int CC_H265 = FourCC('H', '2', '6', '5').vali32;
+    const int CC_HEVC = FourCC('H', 'E', 'V', 'C').vali32;
+
     if (fourcc == CC_X264 || fourcc == CC_H264 || fourcc == CC_AVC)
         return MFX_CODEC_AVC;
     else if (fourcc == CC_H265 || fourcc == CC_HEVC)
index 875b692..f0de318 100644 (file)
@@ -30,24 +30,24 @@ TEST(Videoio_MFX, write_invalid)
 {
     const string filename = cv::tempfile(".264");
     VideoWriter writer;
-    bool res;
-    ASSERT_NO_THROW(res = writer.open(CAP_INTEL_MFX, filename, VideoWriter::fourcc('H', '2', '6', '4'), 1, Size(641, 480), true));
+    bool res = true;
+    ASSERT_NO_THROW(res = writer.open(filename, CAP_INTEL_MFX, VideoWriter::fourcc('H', '2', '6', '4'), 1, Size(641, 480), true));
     EXPECT_FALSE(res);
     EXPECT_FALSE(writer.isOpened());
-    ASSERT_NO_THROW(res = writer.open(CAP_INTEL_MFX,filename, VideoWriter::fourcc('H', '2', '6', '4'), 1, Size(640, 481), true));
+    ASSERT_NO_THROW(res = writer.open(filename, CAP_INTEL_MFX, VideoWriter::fourcc('H', '2', '6', '4'), 1, Size(640, 481), true));
     EXPECT_FALSE(res);
     EXPECT_FALSE(writer.isOpened());
-    ASSERT_NO_THROW(res = writer.open(CAP_INTEL_MFX,filename, VideoWriter::fourcc('A', 'B', 'C', 'D'), 1, Size(640, 480), true));
+    ASSERT_NO_THROW(res = writer.open(filename, CAP_INTEL_MFX, VideoWriter::fourcc('A', 'B', 'C', 'D'), 1, Size(640, 480), true));
     EXPECT_FALSE(res);
     EXPECT_FALSE(writer.isOpened());
-    ASSERT_NO_THROW(res = writer.open(CAP_INTEL_MFX,String(), VideoWriter::fourcc('H', '2', '6', '4'), 1, Size(640, 480), true));
+    ASSERT_NO_THROW(res = writer.open(String(), CAP_INTEL_MFX, VideoWriter::fourcc('H', '2', '6', '4'), 1, Size(640, 480), true));
     EXPECT_FALSE(res);
     EXPECT_FALSE(writer.isOpened());
-    ASSERT_NO_THROW(res = writer.open(CAP_INTEL_MFX,filename, VideoWriter::fourcc('H', '2', '6', '4'), 0, Size(640, 480), true));
+    ASSERT_ANY_THROW(res = writer.open(filename, CAP_INTEL_MFX, VideoWriter::fourcc('H', '2', '6', '4'), 0, Size(640, 480), true));
     EXPECT_FALSE(res);
     EXPECT_FALSE(writer.isOpened());
 
-    ASSERT_NO_THROW(res = writer.open(CAP_INTEL_MFX,filename, VideoWriter::fourcc('H', '2', '6', '4'), 30, Size(640, 480), true));
+    ASSERT_NO_THROW(res = writer.open(filename, CAP_INTEL_MFX, VideoWriter::fourcc('H', '2', '6', '4'), 30, Size(640, 480), true));
     ASSERT_TRUE(res);
     ASSERT_TRUE(writer.isOpened());
     Mat t;
@@ -103,7 +103,7 @@ TEST_P(Videoio_MFX, read_write_raw)
 
     // Write video
     VideoWriter writer;
-    writer.open(CAP_INTEL_MFX, filename, fourcc, FPS, FRAME_SIZE, isColor);
+    writer.open(filename, CAP_INTEL_MFX, fourcc, FPS, FRAME_SIZE, isColor);
     ASSERT_TRUE(writer.isOpened());
     Mat frame(FRAME_SIZE, CV_8UC3);
     for (int i = 0; i < FRAME_COUNT; ++i)
@@ -133,9 +133,9 @@ TEST_P(Videoio_MFX, read_write_raw)
         EXPECT_EQ(goodFrame.type(), frame.type());
         double psnr = cvtest::PSNR(goodFrame, frame);
         if (fourcc == VideoWriter::fourcc('M', 'P', 'G', '2'))
-            EXPECT_GT(psnr, 37); // experimentally chosen value
+            EXPECT_GT(psnr, 31); // experimentally chosen value
         else
-            EXPECT_GT(psnr, 43); // experimentally chosen value
+            EXPECT_GT(psnr, 33); // experimentally chosen value
         goodFrames.pop();
     }
     EXPECT_FALSE(cap.read(frame));