From: Carl Hetherington Date: Wed, 18 Nov 2020 00:31:30 +0000 (+0100) Subject: Remove subtitle language from text content. X-Git-Tag: v2.15.108~34 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=84a0d8a228f36f95ac265bac163c8e3f02dc1fd0 Remove subtitle language from text content. --- diff --git a/src/lib/dcp_subtitle_content.cc b/src/lib/dcp_subtitle_content.cc index f8d12d4e4..43936314b 100644 --- a/src/lib/dcp_subtitle_content.cc +++ b/src/lib/dcp_subtitle_content.cc @@ -69,12 +69,6 @@ DCPSubtitleContent::examine (shared_ptr film, shared_ptr job) /* Default to turning these subtitles on */ only_text()->set_use (true); - if (iop) { - only_text()->set_language (iop->language ()); - } else if (smpte) { - only_text()->set_language (smpte->language().get_value_or ("")); - } - _length = ContentTime::from_seconds (sc->latest_subtitle_out().as_seconds ()); sc->fix_empty_font_ids (); diff --git a/src/lib/text_content.cc b/src/lib/text_content.cc index 901d38647..ecd28d1a0 100644 --- a/src/lib/text_content.cc +++ b/src/lib/text_content.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2018 Carl Hetherington + Copyright (C) 2013-2020 Carl Hetherington This file is part of DCP-o-matic. @@ -47,17 +47,16 @@ int const TextContentProperty::X_SCALE = 502; int const TextContentProperty::Y_SCALE = 503; int const TextContentProperty::USE = 504; int const TextContentProperty::BURN = 505; -int const TextContentProperty::LANGUAGE = 506; -int const TextContentProperty::FONTS = 507; -int const TextContentProperty::COLOUR = 508; -int const TextContentProperty::EFFECT = 509; -int const TextContentProperty::EFFECT_COLOUR = 510; -int const TextContentProperty::LINE_SPACING = 511; -int const TextContentProperty::FADE_IN = 512; -int const TextContentProperty::FADE_OUT = 513; -int const TextContentProperty::OUTLINE_WIDTH = 514; -int const TextContentProperty::TYPE = 515; -int const TextContentProperty::DCP_TRACK = 516; +int const TextContentProperty::FONTS = 506; +int const TextContentProperty::COLOUR = 507; +int const TextContentProperty::EFFECT = 508; +int const TextContentProperty::EFFECT_COLOUR = 509; +int const TextContentProperty::LINE_SPACING = 510; +int const TextContentProperty::FADE_IN = 511; +int const TextContentProperty::FADE_OUT = 512; +int const TextContentProperty::OUTLINE_WIDTH = 513; +int const TextContentProperty::TYPE = 514; +int const TextContentProperty::DCP_TRACK = 515; TextContent::TextContent (Content* parent, TextType type, TextType original_type) : ContentPart (parent) @@ -215,12 +214,6 @@ TextContent::TextContent (Content* parent, cxml::ConstNodePtr node, int version) _fade_out = ContentTime (*fo); } - if (version >= 37) { - _language = node->optional_string_child ("Language").get_value_or (""); - } else { - _language = node->optional_string_child ("SubtitleLanguage").get_value_or (""); - } - list fonts = node->node_children ("Font"); for (list::const_iterator i = fonts.begin(); i != fonts.end(); ++i) { _fonts.push_back (shared_ptr (new Font (*i))); @@ -316,7 +309,6 @@ TextContent::TextContent (Content* parent, vector > c) _y_offset = ref->y_offset (); _x_scale = ref->x_scale (); _y_scale = ref->y_scale (); - _language = ref->language (); _fonts = ref_fonts; _line_spacing = ref->line_spacing (); _fade_in = ref->fade_in (); @@ -343,7 +335,6 @@ TextContent::as_xml (xmlpp::Node* root) const text->add_child("YOffset")->add_child_text (raw_convert (_y_offset)); text->add_child("XScale")->add_child_text (raw_convert (_x_scale)); text->add_child("YScale")->add_child_text (raw_convert (_y_scale)); - text->add_child("Language")->add_child_text (_language); if (_colour) { text->add_child("Red")->add_child_text (raw_convert (_colour->r)); text->add_child("Green")->add_child_text (raw_convert (_colour->g)); @@ -410,9 +401,7 @@ TextContent::identifier () const s += "_" + f->file().get_value_or("Default").string(); } - /* The DCP track and language are for metadata only, and don't affect - how this content looks. - */ + /* The DCP track is for metadata only, and doesn't affect how this content looks */ return s; } @@ -517,12 +506,6 @@ TextContent::set_y_scale (double s) maybe_set (_y_scale, s, TextContentProperty::Y_SCALE); } -void -TextContent::set_language (string language) -{ - maybe_set (_language, language, TextContentProperty::LANGUAGE); -} - void TextContent::set_line_spacing (double s) { diff --git a/src/lib/text_content.h b/src/lib/text_content.h index 5eda8764f..1c7eef19a 100644 --- a/src/lib/text_content.h +++ b/src/lib/text_content.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2019 Carl Hetherington + Copyright (C) 2013-2020 Carl Hetherington This file is part of DCP-o-matic. @@ -40,7 +40,6 @@ public: static int const Y_SCALE; static int const USE; static int const BURN; - static int const LANGUAGE; static int const FONTS; static int const COLOUR; static int const EFFECT; @@ -77,7 +76,6 @@ public: void set_y_offset (double); void set_x_scale (double); void set_y_scale (double); - void set_language (std::string language); void set_colour (dcp::Colour); void unset_colour (); void set_effect (dcp::Effect); @@ -129,11 +127,6 @@ public: return _fonts; } - std::string language () const { - boost::mutex::scoped_lock lm (_mutex); - return _language; - } - boost::optional colour () const { boost::mutex::scoped_lock lm (_mutex); return _colour; @@ -186,10 +179,6 @@ public: static std::list > from_xml (Content* parent, cxml::ConstNodePtr, int version); -protected: - /** subtitle language (e.g. "German") or empty if it is not known */ - std::string _language; - private: friend struct ffmpeg_pts_offset_test; diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 346cbb0c2..79e5ad73b 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -660,15 +660,12 @@ Writer::write_cover_sheet () boost::algorithm::replace_all (text, "$CONTAINER", _film->container()->container_nickname()); boost::algorithm::replace_all (text, "$AUDIO_LANGUAGE", _film->isdcf_metadata().audio_language); - optional subtitle_language; - BOOST_FOREACH (shared_ptr i, _film->content()) { - BOOST_FOREACH (shared_ptr j, i->text) { - if (j->type() == TEXT_OPEN_SUBTITLE && j->use()) { - subtitle_language = j->language (); - } - } + vector subtitle_languages = _film->subtitle_languages(); + if (subtitle_languages.empty()) { + boost::algorithm::replace_all (text, "$SUBTITLE_LANGUAGE", "None"); + } else { + boost::algorithm::replace_all (text, "$SUBTITLE_LANGUAGE", subtitle_languages.front().description()); } - boost::algorithm::replace_all (text, "$SUBTITLE_LANGUAGE", subtitle_language.get_value_or("None")); boost::uintmax_t size = 0; for ( diff --git a/src/wx/text_panel.cc b/src/wx/text_panel.cc index e7f5741bb..f29aea6ff 100644 --- a/src/wx/text_panel.cc +++ b/src/wx/text_panel.cc @@ -60,8 +60,6 @@ TextPanel::TextPanel (ContentPanel* p, TextType t) , _outline_subtitles (0) , _dcp_track_label (0) , _dcp_track (0) - , _language_label (0) - , _language (0) , _text_view (0) , _fonts_dialog (0) , _original_type (t) @@ -157,16 +155,6 @@ TextPanel::setup_visibility () _dcp_track->Destroy (); _dcp_track = 0; } - if (!_language_label) { - _language_label = create_label (this, _("Language"), true); - add_label_to_sizer (_grid, _language_label, true, wxGBPosition(_language_row, 0)); - } - if (!_language) { - _language = new wxTextCtrl (this, wxID_ANY); - _language->Bind (wxEVT_TEXT, boost::bind(&TextPanel::language_changed, this)); - _grid->Add (_language, wxGBPosition(_language_row, 1), wxDefaultSpan, wxEXPAND); - film_content_changed (TextContentProperty::LANGUAGE); - } if (!_outline_subtitles) { _outline_subtitles = new CheckBox (this, _("Show subtitle area")); _outline_subtitles->Bind (wxEVT_CHECKBOX, boost::bind (&TextPanel::outline_subtitles_changed, this)); @@ -175,22 +163,14 @@ TextPanel::setup_visibility () break; case TEXT_CLOSED_CAPTION: - if (_language_label) { - _language_label->Destroy (); - _language_label = 0; - } - if (_language) { - _language->Destroy (); - _language = 0; - } if (!_dcp_track_label) { _dcp_track_label = create_label (this, _("CCAP track"), true); - add_label_to_sizer (_grid, _dcp_track_label, true, wxGBPosition(_language_row, 0)); + add_label_to_sizer (_grid, _dcp_track_label, true, wxGBPosition(_ccap_track_row, 0)); } if (!_dcp_track) { _dcp_track = new wxChoice (this, wxID_ANY); _dcp_track->Bind (wxEVT_CHOICE, boost::bind(&TextPanel::dcp_track_changed, this)); - _grid->Add (_dcp_track, wxGBPosition(_language_row, 1), wxDefaultSpan, wxEXPAND); + _grid->Add (_dcp_track, wxGBPosition(_ccap_track_row, 1), wxDefaultSpan, wxEXPAND); update_dcp_tracks (); film_content_changed (TextContentProperty::DCP_TRACK); } @@ -278,7 +258,7 @@ TextPanel::add_to_grid () ++r; } - _language_row = r; + _ccap_track_row = r; ++r; add_label_to_sizer (_grid, _stream_label, true, wxGBPosition (r, 0)); @@ -468,10 +448,6 @@ TextPanel::film_content_changed (int property) } else if (property == TextContentProperty::LINE_SPACING) { checked_set (_line_spacing, text ? lrint (text->line_spacing() * 100) : 100); clear_outline_subtitles (); - } else if (property == TextContentProperty::LANGUAGE) { - if (_language) { - checked_set (_language, text ? text->language() : ""); - } } else if (property == TextContentProperty::DCP_TRACK) { if (_dcp_track) { update_dcp_track_selection (); @@ -683,15 +659,6 @@ TextPanel::line_spacing_changed () } } -void -TextPanel::language_changed () -{ - DCPOMATIC_ASSERT (_language); - BOOST_FOREACH (shared_ptr i, _parent->selected_text ()) { - i->text_of_original_type(_original_type)->set_language (wx_to_std (_language->GetValue())); - } -} - void TextPanel::content_selection_changed () { @@ -703,7 +670,6 @@ TextPanel::content_selection_changed () film_content_changed (TextContentProperty::X_SCALE); film_content_changed (TextContentProperty::Y_SCALE); film_content_changed (TextContentProperty::LINE_SPACING); - film_content_changed (TextContentProperty::LANGUAGE); film_content_changed (TextContentProperty::FONTS); film_content_changed (TextContentProperty::TYPE); film_content_changed (TextContentProperty::DCP_TRACK); diff --git a/src/wx/text_panel.h b/src/wx/text_panel.h index 7a7b7b504..cd0890e3d 100644 --- a/src/wx/text_panel.h +++ b/src/wx/text_panel.h @@ -45,7 +45,6 @@ private: void y_scale_changed (); void line_spacing_changed (); void dcp_track_changed (); - void language_changed (); void stream_changed (); void text_view_clicked (); void fonts_dialog_clicked (); @@ -90,8 +89,6 @@ private: wxSpinCtrl* _line_spacing; wxStaticText* _dcp_track_label; wxChoice* _dcp_track; - wxStaticText* _language_label; - wxTextCtrl* _language; wxStaticText* _stream_label; wxChoice* _stream; wxButton* _text_view_button; @@ -102,7 +99,7 @@ private: TextType _original_type; int _outline_subtitles_row; - int _language_row; + int _ccap_track_row; boost::weak_ptr _analysis_content; boost::signals2::scoped_connection _analysis_finished_connection; diff --git a/test/isdcf_name_test.cc b/test/isdcf_name_test.cc index b88afb0a0..29bcff6ed 100644 --- a/test/isdcf_name_test.cc +++ b/test/isdcf_name_test.cc @@ -69,9 +69,9 @@ BOOST_AUTO_TEST_CASE (isdcf_name_test) film->_isdcf_date = boost::gregorian::date (2014, boost::gregorian::Jul, 4); film->set_audio_channels (1); film->set_resolution (RESOLUTION_4K); + film->set_subtitle_language (dcp::LanguageTag("fr-FR")); shared_ptr text = content_factory("test/data/subrip.srt").front(); BOOST_REQUIRE_EQUAL (text->text.size(), 1U); - text->text.front()->set_language ("fr"); text->text.front()->set_burn (true); film->examine_and_add_content (text); BOOST_REQUIRE (!wait_for_jobs());