Add equality option for vertical subtitle position. v1.8.34
authorCarl Hetherington <cth@carlh.net>
Thu, 24 Nov 2022 08:54:03 +0000 (09:54 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 24 Nov 2022 08:54:03 +0000 (09:54 +0100)
src/subtitle.cc
src/types.h

index 522b0e5f68919c0449e470987f76897ce3c755ee..de3fe03f82cccdffebdc8d8455af2669321df096 100644 (file)
@@ -37,6 +37,7 @@
  */
 
 
+#include "compose.hpp"
 #include "subtitle.h"
 #include "dcp_time.h"
 
@@ -72,7 +73,7 @@ Subtitle::Subtitle (
 
 
 bool
-Subtitle::equals(shared_ptr<const Subtitle> other, EqualityOptions, NoteHandler note) const
+Subtitle::equals(shared_ptr<const Subtitle> other, EqualityOptions options, NoteHandler note) const
 {
        bool same = true;
 
@@ -96,8 +97,12 @@ Subtitle::equals(shared_ptr<const Subtitle> other, EqualityOptions, NoteHandler
                same = false;
        }
 
-       if (v_position() != other->v_position()) {
-               note(NoteType::ERROR, "subtitle vertical positions differ");
+       auto const vpos = std::abs(v_position() - other->v_position());
+       if (vpos > options.max_subtitle_vertical_position_error)  {
+               note(
+                       NoteType::ERROR,
+                       String::compose("subtitle vertical positions differ by %1 (more than the allowed difference of %2)", vpos, options.max_subtitle_vertical_position_error)
+                   );
                same = false;
        }
 
index 32f1bfc40a8bc9d74337fd50f509832040ef333f..a60193a49d75532b16744a2f5cfa35db6aed4f42 100644 (file)
@@ -259,6 +259,8 @@ struct EqualityOptions
        bool keep_going = false;
        /** true to save the first pair of differeng image subtitles to the current working directory */
        bool export_differing_subtitles = false;
+       /** The maximum allowable absolute difference between the vertical position of subtitles */
+       float max_subtitle_vertical_position_error = 0;
 };