From f528fc50162db6fcecbaa2cd6121c7ee86a82777 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 11 Jan 2017 10:57:09 +0000 Subject: Replace DCP parser with basic version that uses libdcp. --- src/dcp/font.cc | 76 -------------------- src/dcp/font.h | 58 --------------- src/dcp/interop_load_font.cc | 56 --------------- src/dcp/interop_load_font.h | 43 ----------- src/dcp/load_font.h | 38 ---------- src/dcp/smpte_load_font.cc | 31 -------- src/dcp/smpte_load_font.h | 41 ----------- src/dcp/subtitle.cc | 119 ------------------------------- src/dcp/subtitle.h | 58 --------------- src/dcp/text.cc | 65 ----------------- src/dcp/text.h | 57 --------------- src/dcp/wscript | 1 - src/dcp_reader.cc | 165 ++++++++++++++++++++++++------------------- src/dcp_reader.h | 30 +------- src/font_size.cc | 8 +++ src/font_size.h | 1 + src/interop_dcp_reader.cc | 42 ----------- src/interop_dcp_reader.h | 38 ---------- src/reader_factory.cc | 16 +---- src/smpte_dcp_reader.cc | 64 ----------------- src/smpte_dcp_reader.h | 37 ---------- src/wscript | 9 --- 22 files changed, 106 insertions(+), 947 deletions(-) delete mode 100644 src/dcp/font.cc delete mode 100644 src/dcp/font.h delete mode 100644 src/dcp/interop_load_font.cc delete mode 100644 src/dcp/interop_load_font.h delete mode 100644 src/dcp/load_font.h delete mode 100644 src/dcp/smpte_load_font.cc delete mode 100644 src/dcp/smpte_load_font.h delete mode 100644 src/dcp/subtitle.cc delete mode 100644 src/dcp/subtitle.h delete mode 100644 src/dcp/text.cc delete mode 100644 src/dcp/text.h delete mode 100644 src/dcp/wscript delete mode 100644 src/interop_dcp_reader.cc delete mode 100644 src/interop_dcp_reader.h delete mode 100644 src/smpte_dcp_reader.cc delete mode 100644 src/smpte_dcp_reader.h (limited to 'src') diff --git a/src/dcp/font.cc b/src/dcp/font.cc deleted file mode 100644 index 64787c7..0000000 --- a/src/dcp/font.cc +++ /dev/null @@ -1,76 +0,0 @@ -/* - Copyright (C) 2012-2014 Carl Hetherington - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#include "font.h" -#include "text.h" -#include -#include - -using std::string; -using std::list; -using boost::shared_ptr; -using boost::optional; -using namespace sub; - -dcp::Font::Font (cxml::ConstNodePtr node) -{ - id = node->optional_string_attribute ("Id"); - size = node->optional_number_attribute ("Size").get_value_or (0); - italic = node->optional_bool_attribute ("Italic"); - optional c = node->optional_string_attribute ("Color"); - if (c) { - colour = Colour::from_argb_hex (c.get ()); - } - optional const e = node->optional_string_attribute ("Effect"); - if (e) { - effect = string_to_effect (e.get ()); - } - c = node->optional_string_attribute ("EffectColor"); - if (c) { - effect_colour = Colour::from_argb_hex (c.get ()); - } -} - -dcp::Font::Font (std::list > const & font_nodes) - : size (0) - , italic (false) - , colour (Colour::from_argb_hex ("FFFFFFFF")) - , effect_colour (Colour::from_argb_hex ("FFFFFFFF")) -{ - for (list >::const_iterator i = font_nodes.begin(); i != font_nodes.end(); ++i) { - if ((*i)->id) { - id = (*i)->id; - } - if ((*i)->size != 0) { - size = (*i)->size; - } - if ((*i)->italic) { - italic = (*i)->italic.get (); - } - if ((*i)->colour) { - colour = (*i)->colour.get (); - } - if ((*i)->effect) { - effect = (*i)->effect.get (); - } - if ((*i)->effect_colour) { - effect_colour = (*i)->effect_colour.get (); - } - } -} diff --git a/src/dcp/font.h b/src/dcp/font.h deleted file mode 100644 index a1d8223..0000000 --- a/src/dcp/font.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright (C) 2012-2015 Carl Hetherington - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -/** @file src/dcp/font.h - * @brief Font class - */ - -#include "../colour.h" -#include "../effect.h" -#include "subtitle.h" -#include -#include -#include -#include - -namespace sub { -namespace dcp { - -/** @class Font - * @brief Helper class for parsing subtitle XML. - */ -class Font -{ -public: - Font () - : size (0) - {} - - Font (cxml::ConstNodePtr node); - Font (std::list > const & font_nodes); - - boost::optional id; - int size; - boost::optional italic; - boost::optional colour; - boost::optional effect; - boost::optional effect_colour; -}; - -} - -} diff --git a/src/dcp/interop_load_font.cc b/src/dcp/interop_load_font.cc deleted file mode 100644 index 2ee3ee9..0000000 --- a/src/dcp/interop_load_font.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright (C) 2012-2014 Carl Hetherington - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#include "interop_load_font.h" -#include - -using std::string; -using boost::shared_ptr; -using boost::optional; -using namespace sub; - -dcp::InteropLoadFont::InteropLoadFont (string id_, string uri_) - : LoadFont (id_) - , uri (uri_) -{ - -} - -dcp::InteropLoadFont::InteropLoadFont (cxml::ConstNodePtr node) -{ - optional x = node->optional_string_attribute ("Id"); - if (!x) { - x = node->optional_string_attribute ("ID"); - } - id = x.get_value_or (""); - - uri = node->string_attribute ("URI"); -} - -bool -dcp::operator== (InteropLoadFont const & a, InteropLoadFont const & b) -{ - return a.id == b.id && a.uri == b.uri; -} - -bool -dcp::operator!= (InteropLoadFont const & a, InteropLoadFont const & b) -{ - return !(a == b); -} diff --git a/src/dcp/interop_load_font.h b/src/dcp/interop_load_font.h deleted file mode 100644 index 373b26c..0000000 --- a/src/dcp/interop_load_font.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright (C) 2012-2015 Carl Hetherington - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#include "load_font.h" -#include -#include -#include - -namespace sub { -namespace dcp { - -class InteropLoadFont : public LoadFont -{ -public: - InteropLoadFont () {} - InteropLoadFont (std::string id, std::string uri); - InteropLoadFont (cxml::ConstNodePtr node); - - std::string uri; -}; - -bool operator== (InteropLoadFont const & a, InteropLoadFont const & b); -bool operator!= (InteropLoadFont const & a, InteropLoadFont const & b); - -} - -} diff --git a/src/dcp/load_font.h b/src/dcp/load_font.h deleted file mode 100644 index f269c87..0000000 --- a/src/dcp/load_font.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - Copyright (C) 2012-2015 Carl Hetherington - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#include - -namespace sub { -namespace dcp { - -class LoadFont -{ -public: - LoadFont () {} - LoadFont (std::string id_) - : id (id_) - {} - - std::string id; -}; - -} - -} diff --git a/src/dcp/smpte_load_font.cc b/src/dcp/smpte_load_font.cc deleted file mode 100644 index d433cbf..0000000 --- a/src/dcp/smpte_load_font.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2012-2015 Carl Hetherington - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#include "smpte_load_font.h" -#include - -using std::string; -using boost::shared_ptr; -using namespace sub; - -dcp::SMPTELoadFont::SMPTELoadFont (shared_ptr node) - : LoadFont (node->string_attribute ("ID")) -{ - urn = node->content().substr (9); -} diff --git a/src/dcp/smpte_load_font.h b/src/dcp/smpte_load_font.h deleted file mode 100644 index aba05c8..0000000 --- a/src/dcp/smpte_load_font.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright (C) 2012-2014 Carl Hetherington - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#include "load_font.h" -#include -#include - -namespace cxml { - class Node; -} - -namespace sub { -namespace dcp { - -class SMPTELoadFont : public LoadFont -{ -public: - SMPTELoadFont (boost::shared_ptr node); - - std::string urn; -}; - -} - -} diff --git a/src/dcp/subtitle.cc b/src/dcp/subtitle.cc deleted file mode 100644 index 68ca559..0000000 --- a/src/dcp/subtitle.cc +++ /dev/null @@ -1,119 +0,0 @@ -/* - Copyright (C) 2012-2015 Carl Hetherington - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#include "../exceptions.h" -#include "../raw_convert.h" -#include "subtitle.h" -#include -#include -#include - -using std::string; -using std::vector; -using std::list; -using boost::optional; -using boost::shared_ptr; -using boost::lexical_cast; -using boost::is_any_of; -using namespace sub; - -dcp::Subtitle::Subtitle (boost::shared_ptr node, optional tcr) -{ - if (tcr) { - in = smpte_time (node, "TimeIn", tcr.get ()).get (); - out = smpte_time (node, "TimeOut", tcr.get ()).get (); - } else { - in = interop_time (node, "TimeIn").get (); - out = interop_time (node, "TimeOut").get (); - } - - if (tcr) { - fade_up_time = smpte_time (node, "FadeUpTime", tcr.get ()).get_value_or (Time::from_hmsf (0, 0, 0, 2, Rational (tcr.get(), 1))); - fade_down_time = smpte_time (node, "FadeDownTime", tcr.get ()).get_value_or (Time::from_hmsf (0, 0, 0, 2, Rational (tcr.get (), 1))); - } else { - fade_up_time = interop_time (node, "FadeUpTime").get_value_or (Time::from_hms (0, 0, 0, 80)); - if (fade_up_time > Time::from_hms (0, 0, 8, 0)) { - fade_up_time = Time::from_hms (0, 0, 8, 0); - } - fade_down_time = interop_time (node, "FadeDownTime").get_value_or (Time::from_hms (0, 0, 0, 80)); - if (fade_down_time > Time::from_hms (0, 0, 8, 0)) { - fade_down_time = Time::from_hms (0, 0, 8, 0); - } - } -} - -optional