A few tweaks to dcpdiff.
authorCarl Hetherington <cth@carlh.net>
Fri, 3 May 2013 15:12:50 +0000 (16:12 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 3 May 2013 15:12:50 +0000 (16:12 +0100)
src/picture_asset.cc
tools/dcpdiff.cc

index f2982b47d6cbc38690108973ad89418fd65f867e..a505dc63f2efaa094fa2908eda9be3f89db8b460 100644 (file)
@@ -364,13 +364,18 @@ PictureAsset::frame_buffer_equals (
        
        double const std_dev = sqrt (double (total_squared_deviation) / abs_diffs.size());
        
-       if (mean > opt.max_mean_pixel_error || std_dev > opt.max_std_dev_pixel_error) {
-               note (ERROR, "mean or standard deviation out of range for " + lexical_cast<string>(frame));
+       note (NOTE, "mean difference " + lexical_cast<string> (mean) + ", deviation " + lexical_cast<string> (std_dev));
+       
+       if (mean > opt.max_mean_pixel_error) {
+               note (ERROR, "mean " + lexical_cast<string>(mean) + " out of range " + lexical_cast<string>(opt.max_mean_pixel_error) + " in frame " + lexical_cast<string>(frame));
+               return false;
+       }
+
+       if (std_dev > opt.max_std_dev_pixel_error) {
+               note (ERROR, "standard deviation " + lexical_cast<string>(std_dev) + " out of range " + lexical_cast<string>(opt.max_std_dev_pixel_error) + " in frame " + lexical_cast<string>(frame));
                return false;
        }
 
-       note (NOTE, "mean difference " + lexical_cast<string> (mean) + ", deviation " + lexical_cast<string> (std_dev));
-       
        opj_image_destroy (image_A);
        opj_image_destroy (image_B);
 
index 490059aa41ef73aed48fb0e1f143ab7002e0b1a2..b361b93a35a1771b8f8c3b0a8065a5e528f1635c 100644 (file)
@@ -14,10 +14,12 @@ static void
 help (string n)
 {
        cerr << "Syntax: " << n << " [OPTION] <DCP> <DCP>\n"
-            << "  -V, --version      show libdcp version\n"
-            << "  -h, --help         show this help\n"
-            << "  -v, --verbose      be verbose\n"
-            << "  -n, --names        allow differing MXF names\n"
+            << "  -V, --version        show libdcp version\n"
+            << "  -h, --help           show this help\n"
+            << "  -v, --verbose        be verbose\n"
+            << "  -n, --names          allow differing MXF names\n"
+            << "  -m, --mean-pixel     maximum allowed mean pixel error (default 5)\n"
+            << "  -s, --std-dev-pixel  maximum allowed standard deviation of pixel error (default 5)\n"
             << "\n"
             << "The <DCP>s are the DCP directories to compare.\n"
             << "Comparison is of metadata and content, ignoring timestamps\n"
@@ -36,6 +38,8 @@ int
 main (int argc, char* argv[])
 {
        EqualityOptions options;
+       options.max_mean_pixel_error = 5;
+       options.max_std_dev_pixel_error = 5;
        
        int option_index = 0;
        while (1) {
@@ -44,10 +48,12 @@ main (int argc, char* argv[])
                        { "help", no_argument, 0, 'h'},
                        { "verbose", no_argument, 0, 'v'},
                        { "names", no_argument, 0, 'n'},
+                       { "mean-pixel", required_argument, 0, 'm'},
+                       { "std-dev-pixel", required_argument, 0, 's'},
                        { 0, 0, 0, 0 }
                };
 
-               int c = getopt_long (argc, argv, "Vhvn", long_options, &option_index);
+               int c = getopt_long (argc, argv, "Vhvnm:s:", long_options, &option_index);
 
                if (c == -1) {
                        break;
@@ -66,6 +72,12 @@ main (int argc, char* argv[])
                case 'n':
                        options.mxf_names_can_differ = true;
                        break;
+               case 'm':
+                       options.max_mean_pixel_error = atof (optarg);
+                       break;
+               case 's':
+                       options.max_std_dev_pixel_error = atof (optarg);
+                       break;
                }
        }
 
@@ -102,8 +114,6 @@ main (int argc, char* argv[])
                exit (EXIT_FAILURE);
        }
 
-       options.max_mean_pixel_error = 5;
-       options.max_std_dev_pixel_error = 5;
        /* I think this is just below the LSB at 16-bits (ie the 8th most significant bit at 24-bit) */
        options.max_audio_sample_error = 255;