From 689bf63d32a8276477ab12e83bd47a5ff67d3eae Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 12 Aug 2021 01:29:24 +0200 Subject: Don't write empty nodes in subtitles/closed captions. --- src/lib/reel_writer.cc | 56 ++++++++++++++++++++++++++------------------------ src/lib/reel_writer.h | 2 +- 2 files changed, 30 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index 521ba55df..7b9ea09bf 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -641,7 +641,7 @@ ReelWriter::create_reel_text ( } else if (ensure_subtitles) { /* We had no subtitle asset, but we've been asked to make sure there is one */ subtitle = maybe_add_text ( - empty_text_asset(TextType::OPEN_SUBTITLE, optional()), + empty_text_asset(TextType::OPEN_SUBTITLE, optional(), true), duration, reel, refs, @@ -670,7 +670,7 @@ ReelWriter::create_reel_text ( /* Make empty tracks for anything we've been asked to ensure but that we haven't added */ for (auto i: ensure_closed_captions) { auto a = maybe_add_text ( - empty_text_asset(TextType::CLOSED_CAPTION, i), duration, reel, refs, fonts, _default_font, film(), _period, output_dcp, _text_only + empty_text_asset(TextType::CLOSED_CAPTION, i, true), duration, reel, refs, fonts, _default_font, film(), _period, output_dcp, _text_only ); DCPOMATIC_ASSERT (a); a->set_annotation_text (i.name); @@ -784,7 +784,7 @@ ReelWriter::write (shared_ptr audio) shared_ptr -ReelWriter::empty_text_asset (TextType type, optional track) const +ReelWriter::empty_text_asset (TextType type, optional track, bool with_dummy) const { shared_ptr asset; @@ -815,29 +815,31 @@ ReelWriter::empty_text_asset (TextType type, optional track) const if (film()->encrypted()) { s->set_key (film()->key()); } - s->add ( - std::make_shared( - optional(), - false, - false, - false, - dcp::Colour(), - 42, - 1.0, - dcp::Time(0, 0, 0, 0, 24), - dcp::Time(0, 0, 1, 0, 24), - 0.5, - dcp::HAlign::CENTER, - 0.5, - dcp::VAlign::CENTER, - dcp::Direction::LTR, - "", - dcp::Effect::NONE, - dcp::Colour(), - dcp::Time(), - dcp::Time() - ) - ); + if (with_dummy) { + s->add ( + std::make_shared( + optional(), + false, + false, + false, + dcp::Colour(), + 42, + 1.0, + dcp::Time(0, 0, 0, 0, 24), + dcp::Time(0, 0, 1, 0, 24), + 0.5, + dcp::HAlign::CENTER, + 0.5, + dcp::VAlign::CENTER, + dcp::Direction::LTR, + " ", + dcp::Effect::NONE, + dcp::Colour(), + dcp::Time(), + dcp::Time() + ) + ); + } asset = s; } @@ -863,7 +865,7 @@ ReelWriter::write (PlayerText subs, TextType type, optional track, } if (!asset) { - asset = empty_text_asset (type, track); + asset = empty_text_asset (type, track, false); } switch (type) { diff --git a/src/lib/reel_writer.h b/src/lib/reel_writer.h index 804a93c05..5de00f641 100644 --- a/src/lib/reel_writer.h +++ b/src/lib/reel_writer.h @@ -103,7 +103,7 @@ private: long frame_info_position (Frame frame, Eyes eyes) const; Frame check_existing_picture_asset (boost::filesystem::path asset); bool existing_picture_frame_ok (FILE* asset_file, std::shared_ptr info_file, Frame frame) const; - std::shared_ptr empty_text_asset (TextType type, boost::optional track) const; + std::shared_ptr empty_text_asset (TextType type, boost::optional track, bool with_dummy) const; std::shared_ptr create_reel_picture (std::shared_ptr reel, std::list const & refs) const; void create_reel_sound (std::shared_ptr reel, std::list const & refs) const; -- cgit v1.2.3