summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-11-24 09:54:03 +0100
committerCarl Hetherington <cth@carlh.net>2022-11-24 09:54:03 +0100
commite46870be9e7544d102b9612680b321fbf52c73f2 (patch)
tree239548909916f9388e9ca8e259a7348738906e61
parent870b1613e1e6333db01185548574efb3277de060 (diff)
Add equality option for vertical subtitle position.v1.8.34
-rw-r--r--src/subtitle.cc11
-rw-r--r--src/types.h2
2 files changed, 10 insertions, 3 deletions
diff --git a/src/subtitle.cc b/src/subtitle.cc
index 522b0e5f..de3fe03f 100644
--- a/src/subtitle.cc
+++ b/src/subtitle.cc
@@ -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;
}
diff --git a/src/types.h b/src/types.h
index 32f1bfc4..a60193a4 100644
--- a/src/types.h
+++ b/src/types.h
@@ -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;
};