From 235b00b6ee449b1ada473a04cfee3d235e429a2e Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Wed, 30 Aug 2017 18:08:36 +0300 Subject: [PATCH] Fixed MediaSDK tests and build warnings --- modules/videoio/src/cap_mfx_common.hpp | 10 ---------- modules/videoio/src/cap_mfx_writer.cpp | 7 +++++++ modules/videoio/test/test_mfx.cpp | 20 ++++++++++---------- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/modules/videoio/src/cap_mfx_common.hpp b/modules/videoio/src/cap_mfx_common.hpp index aea0164..1e97849 100644 --- a/modules/videoio/src/cap_mfx_common.hpp +++ b/modules/videoio/src/cap_mfx_common.hpp @@ -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 inline void cleanup(T * &ptr) { diff --git a/modules/videoio/src/cap_mfx_writer.cpp b/modules/videoio/src/cap_mfx_writer.cpp index 9fc0063..6f8700a 100644 --- a/modules/videoio/src/cap_mfx_writer.cpp +++ b/modules/videoio/src/cap_mfx_writer.cpp @@ -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) diff --git a/modules/videoio/test/test_mfx.cpp b/modules/videoio/test/test_mfx.cpp index 875b692..f0de318 100644 --- a/modules/videoio/test/test_mfx.cpp +++ b/modules/videoio/test/test_mfx.cpp @@ -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)); -- 2.7.4