Try relaxing image check slightly.
[dcpomatic.git] / test / test.cc
index 1ca06c105584b43baa5d71961f70babe1a6b2639..76678b74be4ba77bd0957dfb2e6b8a0b1ceda7a2 100644 (file)
@@ -236,7 +236,15 @@ check_image (boost::filesystem::path ref, boost::filesystem::path check)
        ref_image.read (ref.string ());
        Magick::Image check_image;
        check_image.read (check.string ());
-       BOOST_CHECK_MESSAGE (ref_image.compare (check_image), ref << " differs from " << check);
+       /* XXX: this is a hack; we really want the ImageMagick call but GraphicsMagick doesn't have it;
+          this may cause random test failures on platforms that use GraphicsMagick.
+       */
+#ifdef DCPOMATIC_ADVANCED_MAGICK_COMPARE
+       double const dist = ref_image.compare(check_image, Magick::RootMeanSquaredErrorMetric);
+       BOOST_CHECK_MESSAGE (dist < 0.01, ref << " differs from " << check << " " << dist);
+#else
+       BOOST_CHECK_MESSAGE (!ref_image.compare(check_image), ref << " differs from " << check);
+#endif
 }
 
 void
@@ -422,30 +430,11 @@ write_image (shared_ptr<const Image> image, boost::filesystem::path file, string
        m.write (file.string ());
 }
 
-static
-void
-check_ffmpeg_stream (boost::filesystem::path ref, boost::filesystem::path check, string stream)
-{
-       FILE* ref_file = popen(string("ffmpeg -loglevel error -i " + ref.string() + " -map 0:" + stream + " -f md5 -").c_str(), "r");
-       BOOST_REQUIRE (ref_file);
-       char ref_md5[64];
-       fscanf (ref_file, "%63s", ref_md5);
-       pclose (ref_file);
-
-       FILE* check_file = popen(string("ffmpeg -loglevel error -i " + check.string() + " -map 0:" + stream + " -f md5 -").c_str(), "r");
-       BOOST_REQUIRE (check_file);
-       char check_md5[64];
-       fscanf (check_file, "%63s", check_md5);
-       pclose (check_file);
-
-       BOOST_REQUIRE_EQUAL (strcmp(ref_md5, check_md5), 0);
-}
-
 void
-check_ffmpeg (boost::filesystem::path ref, boost::filesystem::path check, int skip_packet_stream)
+check_ffmpeg (boost::filesystem::path ref, boost::filesystem::path check)
 {
-       check_ffmpeg_stream (ref, check, "v");
-       check_ffmpeg_stream (ref, check, "a");
+       int const r = system (string("ffcmp " + ref.string() + " " + check.string()).c_str());
+       BOOST_REQUIRE_EQUAL (WEXITSTATUS(r), 0);
 }
 
 void