mirror of
https://github.com/opencv/opencv.git
synced 2025-07-30 17:37:05 +08:00
Merge pull request #9527 from mshabunin:mediasdk-fix
This commit is contained in:
commit
4acdcfd008
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user