Commit 4acdcfd0 authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #9527 from mshabunin:mediasdk-fix

parents 273add5d 235b00b6
...@@ -156,16 +156,6 @@ inline std::ostream & operator<<(std::ostream &out, const mfxFrameData &data) { ...@@ -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> template <typename T>
inline void cleanup(T * &ptr) inline void cleanup(T * &ptr)
{ {
......
...@@ -11,6 +11,13 @@ using namespace cv; ...@@ -11,6 +11,13 @@ using namespace cv;
inline mfxU32 codecIdByFourCC(int fourcc) 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) if (fourcc == CC_X264 || fourcc == CC_H264 || fourcc == CC_AVC)
return MFX_CODEC_AVC; return MFX_CODEC_AVC;
else if (fourcc == CC_H265 || fourcc == CC_HEVC) else if (fourcc == CC_H265 || fourcc == CC_HEVC)
......
...@@ -30,24 +30,24 @@ TEST(Videoio_MFX, write_invalid) ...@@ -30,24 +30,24 @@ TEST(Videoio_MFX, write_invalid)
{ {
const string filename = cv::tempfile(".264"); const string filename = cv::tempfile(".264");
VideoWriter writer; VideoWriter writer;
bool res; bool res = true;
ASSERT_NO_THROW(res = writer.open(CAP_INTEL_MFX, filename, VideoWriter::fourcc('H', '2', '6', '4'), 1, Size(641, 480), 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(res);
EXPECT_FALSE(writer.isOpened()); 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(res);
EXPECT_FALSE(writer.isOpened()); 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(res);
EXPECT_FALSE(writer.isOpened()); 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(res);
EXPECT_FALSE(writer.isOpened()); 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(res);
EXPECT_FALSE(writer.isOpened()); 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(res);
ASSERT_TRUE(writer.isOpened()); ASSERT_TRUE(writer.isOpened());
Mat t; Mat t;
...@@ -103,7 +103,7 @@ TEST_P(Videoio_MFX, read_write_raw) ...@@ -103,7 +103,7 @@ TEST_P(Videoio_MFX, read_write_raw)
// Write video // Write video
VideoWriter writer; 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()); ASSERT_TRUE(writer.isOpened());
Mat frame(FRAME_SIZE, CV_8UC3); Mat frame(FRAME_SIZE, CV_8UC3);
for (int i = 0; i < FRAME_COUNT; ++i) for (int i = 0; i < FRAME_COUNT; ++i)
...@@ -133,9 +133,9 @@ TEST_P(Videoio_MFX, read_write_raw) ...@@ -133,9 +133,9 @@ TEST_P(Videoio_MFX, read_write_raw)
EXPECT_EQ(goodFrame.type(), frame.type()); EXPECT_EQ(goodFrame.type(), frame.type());
double psnr = cvtest::PSNR(goodFrame, frame); double psnr = cvtest::PSNR(goodFrame, frame);
if (fourcc == VideoWriter::fourcc('M', 'P', 'G', '2')) if (fourcc == VideoWriter::fourcc('M', 'P', 'G', '2'))
EXPECT_GT(psnr, 37); // experimentally chosen value EXPECT_GT(psnr, 31); // experimentally chosen value
else else
EXPECT_GT(psnr, 43); // experimentally chosen value EXPECT_GT(psnr, 33); // experimentally chosen value
goodFrames.pop(); goodFrames.pop();
} }
EXPECT_FALSE(cap.read(frame)); EXPECT_FALSE(cap.read(frame));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment