Media foundation video i/o fixes.

Bug in Video for Windows capture init fixed;
Media Foundation based capture finalization fixed;
Highgui tests for video i/o updated.
This commit is contained in:
Alexander Smorkalov
2013-05-22 04:21:23 -07:00
parent 996f02a531
commit 43122939cb
5 changed files with 110 additions and 133 deletions

View File

@@ -57,27 +57,27 @@ string fourccToString(int fourcc)
#ifdef HAVE_MSMF
const VideoFormat g_specific_fmt_list[] =
{
/* VideoFormat("avi", 'dv25'),
VideoFormat("avi", 'dv50'),
VideoFormat("avi", 'dvc '),
VideoFormat("avi", 'dvh1'),
VideoFormat("avi", 'dvhd'),
VideoFormat("avi", 'dvsd'),
VideoFormat("avi", 'dvsl'),
VideoFormat("avi", 'M4S2'), */
VideoFormat("wmv", 'WMV3'),
// VideoFormat("avi", 'H264'),
// VideoFormat("avi", 'MJPG'),
// VideoFormat("avi", 'MP43'),
// VideoFormat("avi", 'MP4S'),
// VideoFormat("avi", 'MP4V'),
/* VideoFormat("avi", 'MPG1'),
VideoFormat("avi", 'MSS1'),
VideoFormat("avi", 'MSS2'),
VideoFormat("avi", 'WMV1'),
VideoFormat("avi", 'WMV2'),
VideoFormat("avi", 'WMV3'),
VideoFormat("avi", 'WVC1'), */
/*VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', '2', '5')),
VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', '5', '0')),
VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 'c', ' ')),
VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 'h', '1')),
VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 'h', 'd')),
VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 's', 'd')),
VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 's', 'l')),
VideoFormat("wmv", CV_FOURCC_MACRO('H', '2', '6', '3')),
VideoFormat("wmv", CV_FOURCC_MACRO('M', '4', 'S', '2')),
VideoFormat("avi", CV_FOURCC_MACRO('M', 'J', 'P', 'G')),
VideoFormat("mp4", CV_FOURCC_MACRO('M', 'P', '4', 'S')),
VideoFormat("mp4", CV_FOURCC_MACRO('M', 'P', '4', 'V')),
VideoFormat("wmv", CV_FOURCC_MACRO('M', 'P', '4', '3')),
VideoFormat("wmv", CV_FOURCC_MACRO('M', 'P', 'G', '1')),
VideoFormat("wmv", CV_FOURCC_MACRO('M', 'S', 'S', '1')),
VideoFormat("wmv", CV_FOURCC_MACRO('M', 'S', 'S', '2')),*/
//VideoFormat("avi", CV_FOURCC_MACRO('H', '2', '6', '4')),
VideoFormat("wmv", CV_FOURCC_MACRO('W', 'M', 'V', '1')),
VideoFormat("wmv", CV_FOURCC_MACRO('W', 'M', 'V', '2')),
VideoFormat("wmv", CV_FOURCC_MACRO('W', 'M', 'V', '3')),
//VideoFormat("wmv", CV_FOURCC_MACRO('W', 'V', 'C', '1')),
VideoFormat()
};
#else
@@ -269,19 +269,19 @@ void CV_HighGuiTest::VideoTest(const string& dir, const cvtest::VideoFormat& fmt
for(;;)
{
IplImage * img = cvQueryFrame( cap );
IplImage* img = cvQueryFrame( cap );
if (!img)
break;
frames.push_back(Mat(img).clone());
if (writer == 0)
if (writer == NULL)
{
writer = cvCreateVideoWriter(tmp_name.c_str(), fmt.fourcc, 24, cvGetSize(img));
if (writer == 0)
if (writer == NULL)
{
ts->printf(ts->LOG, "can't create writer (with fourcc : %d)\n",
ts->printf(ts->LOG, "can't create writer (with fourcc : %s)\n",
cvtest::fourccToString(fmt.fourcc).c_str());
cvReleaseCapture( &cap );
ts->set_failed_test_info(ts->FAIL_MISMATCH);
@@ -317,18 +317,22 @@ void CV_HighGuiTest::VideoTest(const string& dir, const cvtest::VideoFormat& fmt
double psnr = PSNR(img1, img);
if (psnr < thresDbell)
{
printf("Too low psnr = %gdb\n", psnr);
ts->printf(ts->LOG, "Too low frame %d psnr = %gdb\n", i, psnr);
ts->set_failed_test_info(ts->FAIL_MISMATCH);
//imwrite("original.png", img);
//imwrite("after_test.png", img1);
//Mat diff;
//absdiff(img, img1, diff);
//imwrite("diff.png", diff);
ts->set_failed_test_info(ts->FAIL_MISMATCH);
break;
}
}
printf("Before saved release for %s\n", tmp_name.c_str());
cvReleaseCapture( &saved );
printf("After release\n");
ts->printf(ts->LOG, "end test function : ImagesVideo \n");
}