Add direction support for SMPTE subtitles; fix pragma warnings with non-openmp builds.
authorCarl Hetherington <cth@carlh.net>
Tue, 12 Apr 2016 00:37:00 +0000 (01:37 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 12 Apr 2016 00:37:00 +0000 (01:37 +0100)
15 files changed:
src/mono_picture_asset.cc
src/object.h
src/smpte_subtitle_asset.h
src/subtitle_asset.cc
src/subtitle_string.cc
src/subtitle_string.h
src/text_node.cc
src/text_node.h
src/types.cc
src/types.h
test/data/subs2.xml
test/make_digest_test.cc
test/read_interop_subtitle_test.cc
test/write_subtitle_test.cc
wscript

index b367a19de3d7f649a8636745a91477744809c308..8e09d8c68c67679e7f7158a47518996607b10c28 100644 (file)
@@ -113,7 +113,10 @@ MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, No
 
        bool result = true;
 
+#ifdef LIBDCP_OPENMP
 #pragma omp parallel for
+#endif
+
        for (int i = 0; i < _intrinsic_duration; ++i) {
                if (i >= other_picture->intrinsic_duration()) {
                        result = false;
@@ -134,7 +137,9 @@ MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, No
                                result = false;
                        }
 
+#ifdef LIBDCP_OPENMP
 #pragma omp critical
+#endif
                        {
                                note (DCP_PROGRESS, String::compose ("Compared video frame %1 of %2", i, _intrinsic_duration));
                                for (list<pair<NoteType, string> >::const_iterator i = notes.begin(); i != notes.end(); ++i) {
index 303e46d33c2793c77e5ce9833e4a0f8c76d79d3c..0fa112513a68523bd8bfc20c30a41432d94dbdd5 100644 (file)
@@ -27,7 +27,8 @@
 #include <boost/noncopyable.hpp>
 #include <string>
 
-class write_subtitle_test;
+class write_interop_subtitle_test;
+class write_smpte_subtitle_test;
 
 namespace dcp {
 
@@ -47,7 +48,8 @@ public:
        }
 
 protected:
-       friend class ::write_subtitle_test;
+       friend class ::write_interop_subtitle_test;
+       friend class ::write_smpte_subtitle_test;
 
        /** ID */
        std::string _id;
index a7adee6faa29919856e74a410c366332864e46fc..48a0b95c0223ee964ed5e1211002bee496044f06 100644 (file)
@@ -69,6 +69,10 @@ public:
                _language = l;
        }
 
+       void set_issue_date (LocalTime t) {
+               _issue_date = t;
+       }
+
        void set_reel_number (int r) {
                _reel_number = r;
        }
index 352aff9a2efc8bed31d7403f22298eb96234b8a3..89c9679567a6c774b4d15654b12d170b21d84e96 100644 (file)
@@ -153,6 +153,7 @@ SubtitleAsset::maybe_add_subtitle (string text, ParseState const & parse_state)
                        effective_text.h_align,
                        effective_text.v_position,
                        effective_text.v_align,
+                       effective_text.direction,
                        text,
                        effective_font.effect.get_value_or (NONE),
                        effective_font.effect_colour.get_value_or (dcp::Colour (0, 0, 0)),
@@ -333,6 +334,7 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Stand
                }
 
                xmlpp::Element* text = subtitle_element->add_child ("Text", xmlns);
+
                if (i.h_align() != HALIGN_CENTER) {
                        if (standard == SMPTE) {
                                text->set_attribute ("Halign", halign_to_string (i.h_align ()));
@@ -340,6 +342,7 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Stand
                                text->set_attribute ("HAlign", halign_to_string (i.h_align ()));
                        }
                }
+
                if (i.h_position() > ALIGN_EPSILON) {
                        if (standard == SMPTE) {
                                text->set_attribute ("Hposition", raw_convert<string> (i.h_position() * 100, 6));
@@ -347,11 +350,13 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Stand
                                text->set_attribute ("HPosition", raw_convert<string> (i.h_position() * 100, 6));
                        }
                }
+
                if (standard == SMPTE) {
                        text->set_attribute ("Valign", valign_to_string (i.v_align()));
                } else {
                        text->set_attribute ("VAlign", valign_to_string (i.v_align()));
                }
+
                if (i.v_position() > ALIGN_EPSILON) {
                        if (standard == SMPTE) {
                                text->set_attribute ("Vposition", raw_convert<string> (i.v_position() * 100, 6));
@@ -365,6 +370,14 @@ SubtitleAsset::subtitles_as_xml (xmlpp::Element* root, int time_code_rate, Stand
                                text->set_attribute ("VPosition", "0");
                        }
                }
+
+               /* Interop only supports "horizontal" or "vertical" for direction, so only write this
+                  for SMPTE.
+               */
+               if (i.direction() != DIRECTION_LTR && standard == SMPTE) {
+                       text->set_attribute ("Direction", direction_to_string (i.direction ()));
+               }
+
                text->add_child_text (i.text());
        }
 }
index ea24e37f122aa1ad91f070d1877912c4600a213b..7ba6e0e112910748f69e6f949d77c9020ba9fffb 100644 (file)
@@ -40,6 +40,7 @@ SubtitleString::SubtitleString (
        HAlign h_align,
        float v_position,
        VAlign v_align,
+       Direction direction,
        string text,
        Effect effect,
        Colour effect_colour,
@@ -58,6 +59,7 @@ SubtitleString::SubtitleString (
        , _h_align (h_align)
        , _v_position (v_position)
        , _v_align (v_align)
+       , _direction (direction)
        , _text (text)
        , _effect (effect)
        , _effect_colour (effect_colour)
@@ -94,6 +96,7 @@ dcp::operator== (SubtitleString const & a, SubtitleString const & b)
                a.h_align() == b.h_align() &&
                a.v_position() == b.v_position() &&
                a.v_align() == b.v_align() &&
+               a.direction() == b.direction() &&
                a.text() == b.text() &&
                a.effect() == b.effect() &&
                a.effect_colour() == b.effect_colour() &&
@@ -124,6 +127,7 @@ dcp::operator<< (ostream& s, SubtitleString const & sub)
        s << "size " << sub.size() << ", aspect " << sub.aspect_adjust() << ", colour " << sub.colour()
          << ", vpos " << sub.v_position() << ", valign " << ((int) sub.v_align())
          << ", hpos " << sub.h_position() << ", halign " << ((int) sub.h_align())
+         << ", direction " << ((int) sub.direction())
          << ", effect " << ((int) sub.effect()) << ", effect colour " << sub.effect_colour();
 
        return s;
index bd71b8da6b93e09c96f16651e31e714ddeb54abe..6cf1713dc2c4f370644dce277906df9f0e55acdb 100644 (file)
@@ -50,6 +50,7 @@ public:
                HAlign h_align,
                float v_position,
                VAlign v_align,
+               Direction direction,
                std::string text,
                Effect effect,
                Colour effect_colour,
@@ -106,6 +107,10 @@ public:
                return _v_align;
        }
 
+       Direction direction () const {
+               return _direction;
+       }
+
        Effect effect () const {
                return _effect;
        }
@@ -189,6 +194,7 @@ private:
         */
        float _v_position;
        VAlign _v_align;
+       Direction _direction;
        std::string _text;
        Effect _effect;
        Colour _effect_colour;
index aa318ce75b4e4b6c6c425b45148258baa8b1ab0b..7618c460da7d42e3810692e43e86d76f99cc0796 100644 (file)
@@ -42,6 +42,7 @@ TextNode::TextNode (boost::shared_ptr<const cxml::Node> node, int tcr, string fo
        , h_align (HALIGN_CENTER)
        , v_position (0)
        , v_align (VALIGN_CENTER)
+       , direction (DIRECTION_LTR)
 {
        text = node->content ();
 
@@ -77,6 +78,11 @@ TextNode::TextNode (boost::shared_ptr<const cxml::Node> node, int tcr, string fo
                v_align = string_to_valign (va.get ());
        }
 
+       optional<string> d = node->optional_string_attribute ("Direction");
+       if (d) {
+               direction = string_to_direction (d.get ());
+       }
+
        list<cxml::NodePtr> f = node->node_children ("Font");
        BOOST_FOREACH (cxml::NodePtr& i, f) {
                font_nodes.push_back (shared_ptr<FontNode> (new FontNode (i, tcr, font_id_attribute)));
index f10d7c4b73b33db4854f7729a777adcf1c211d8a..753d1a0188611f4e0a6c176463190d87054d8e3f 100644 (file)
@@ -46,6 +46,7 @@ public:
                , h_align (HALIGN_LEFT)
                , v_position (0)
                , v_align (VALIGN_TOP)
+               , direction (DIRECTION_LTR)
        {}
 
        TextNode (boost::shared_ptr<const cxml::Node> node, int tcr, std::string font_id_attribute);
@@ -54,6 +55,7 @@ public:
        HAlign h_align;
        float v_position;
        VAlign v_align;
+       Direction direction;
        std::string text;
        std::list<boost::shared_ptr<FontNode> > font_nodes;
 };
index 687e90f81fa21f3b9d56195e892bd63fbe4bd6fb..30c565c90813af1ba5307bfce1af7a06ee11e4fc 100644 (file)
@@ -232,3 +232,36 @@ dcp::string_to_valign (string s)
 
        boost::throw_exception (DCPReadError ("unknown subtitle valign type"));
 }
+
+string
+dcp::direction_to_string (Direction v)
+{
+       switch (v) {
+       case DIRECTION_LTR:
+               return "ltr";
+       case DIRECTION_RTL:
+               return "rtl";
+       case DIRECTION_TTB:
+               return "ttb";
+       case DIRECTION_BTT:
+               return "btt";
+       }
+
+       boost::throw_exception (MiscError ("unknown subtitle direction type"));
+}
+
+Direction
+dcp::string_to_direction (string s)
+{
+       if (s == "ltr") {
+               return DIRECTION_LTR;
+       } else if (s == "rtl") {
+               return DIRECTION_RTL;
+       } else if (s == "ttb") {
+               return DIRECTION_TTB;
+       } else if (s == "btt") {
+               return DIRECTION_BTT;
+       }
+
+       boost::throw_exception (DCPReadError ("unknown subtitle direction type"));
+}
index 16000daa809c8a58b342461e31e2bbd3169363c8..0f05d889f07db6a406c17a2208de683f7221c27e 100644 (file)
@@ -114,6 +114,18 @@ enum VAlign
 extern std::string valign_to_string (VAlign a);
 extern VAlign string_to_valign (std::string s);
 
+/** Direction for subtitle test */
+enum Direction
+{
+       DIRECTION_LTR, ///< left-to-right
+       DIRECTION_RTL, ///< right-to-left
+       DIRECTION_TTB, ///< top-to-bottom
+       DIRECTION_BTT  ///< bottom-to-top
+};
+
+extern std::string direction_to_string (Direction a);
+extern Direction string_to_direction (std::string s);
+
 enum Eye
 {
        EYE_LEFT,
index c0001b06f9b86f8204df57ec09b0ce932f7afbbb..a6ec2338a6a58594237560327116d13965894ac8 100755 (executable)
                        </Subtitle>
                        <Subtitle SpotNumber="4" TimeIn="00:01:15:042" TimeOut="00:01:16:042" FadeUpTime="0" FadeDownTime="0">
                                <Font Italic="yes">
-                                       <Text HAlign="center" HPosition="0" VAlign="top" VPosition="89" ZPosition="0.5">With the legendary Miss Enid Blyton</Text>
+                                       <Text HAlign="center" HPosition="0" VAlign="top" VPosition="89" ZPosition="0.5" Direction="rtl">With the legendary Miss Enid Blyton</Text>
                                </Font>
                                <Font Italic="yes">
-                                       <Text HAlign="center" HPosition="0" VAlign="top" VPosition="95" ZPosition="0.5">She said "you be Noddy</Text>
+                                       <Text HAlign="center" HPosition="0" VAlign="top" VPosition="95" ZPosition="0.5" Direction="ttb">She said "you be Noddy</Text>
                                </Font>
                        </Subtitle>
                        <Subtitle SpotNumber="5" TimeIn="00:01:20:219" TimeOut="00:01:22:073" FadeUpTime="0" FadeDownTime="0">
@@ -48,7 +48,7 @@
                        </Subtitle>
                        <Subtitle SpotNumber="6" TimeIn="00:01:27:115" TimeOut="00:01:28:208" FadeUpTime="0" FadeDownTime="0">
                                <Font Italic="yes">
-                                       <Text HAlign="center" HPosition="0" VAlign="top" VPosition="89" ZPosition="0.5">That curious creature the Sphinx</Text>
+                                       <Text HAlign="center" HPosition="0" VAlign="top" VPosition="89" ZPosition="0.5" Direction="btt">That curious creature the Sphinx</Text>
                                </Font>
                                <Font Italic="yes">
                                        <Text HAlign="center" HPosition="0" VAlign="top" VPosition="95" ZPosition="0.5">Is smarter than anyone thinks</Text>
index 4614911e460c9886f8ae5afa9b21ed65184957b7..b7e18a127f2be5987d580e2eefb5a371ebca98f1 100644 (file)
@@ -22,7 +22,6 @@
 #include <boost/bind.hpp>
 #include <boost/test/unit_test.hpp>
 #include <sys/time.h>
-#include <iostream>
 
 void progress (float)
 {
@@ -43,13 +42,5 @@ BOOST_AUTO_TEST_CASE (make_digest_test)
        data.write ("build/test/random");
 
        /* Hash it */
-       struct timeval A;
-       gettimeofday (&A, 0);
-       for (int i = 0; i < 64; ++i) {
-               BOOST_CHECK_EQUAL (dcp::make_digest ("build/test/random", boost::bind (&progress, _1)), "GKbk/V3fcRtP5MaPdSmAGNbKkaU=");
-       }
-       struct timeval B;
-       gettimeofday (&B, 0);
-
-       std::cout << ((B.tv_sec + B.tv_usec / 1e6) - (A.tv_sec + A.tv_usec / 1e6)) << "\n";
+       BOOST_CHECK_EQUAL (dcp::make_digest ("build/test/random", boost::bind (&progress, _1)), "GKbk/V3fcRtP5MaPdSmAGNbKkaU=");
 }
index 7822d47e9f8c015dc789829633853c68b266b6fa..8640b7ef2892bfe6528b8f4468abac3826e46c61 100644 (file)
@@ -59,6 +59,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test1)
                                   dcp::HALIGN_CENTER,
                                   0.15,
                                   dcp::VALIGN_BOTTOM,
+                                  dcp::DIRECTION_LTR,
                                   "My jacket was Idi Amin's",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
@@ -81,6 +82,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test1)
                                   dcp::HALIGN_CENTER,
                                   0.21,
                                   dcp::VALIGN_BOTTOM,
+                                  dcp::DIRECTION_LTR,
                                   "My corset was H.M. The Queen's",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
@@ -100,6 +102,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test1)
                                   dcp::HALIGN_CENTER,
                                   0.15,
                                   dcp::VALIGN_BOTTOM,
+                                  dcp::DIRECTION_LTR,
                                   "My large wonderbra",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
@@ -122,6 +125,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test1)
                                   dcp::HALIGN_CENTER,
                                   0.15,
                                   dcp::VALIGN_BOTTOM,
+                                  dcp::DIRECTION_LTR,
                                   "Once belonged to the Shah",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
@@ -144,6 +148,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test1)
                                   dcp::HALIGN_CENTER,
                                   0.15,
                                   dcp::VALIGN_BOTTOM,
+                                  dcp::DIRECTION_LTR,
                                   "And these are Roy Hattersley's jeans",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
@@ -172,6 +177,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
                                   dcp::HALIGN_CENTER,
                                   0.89,
                                   dcp::VALIGN_TOP,
+                                  dcp::DIRECTION_LTR,
                                   "At afternoon tea with John Peel",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
@@ -191,6 +197,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
                                   dcp::HALIGN_CENTER,
                                   0.95,
                                   dcp::VALIGN_TOP,
+                                  dcp::DIRECTION_LTR,
                                   "I enquired if his accent was real",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
@@ -213,6 +220,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
                                   dcp::HALIGN_CENTER,
                                   0.89,
                                   dcp::VALIGN_TOP,
+                                  dcp::DIRECTION_LTR,
                                   "He said \"out of the house",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
@@ -232,6 +240,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
                                   dcp::HALIGN_CENTER,
                                   0.95,
                                   dcp::VALIGN_TOP,
+                                  dcp::DIRECTION_LTR,
                                   "I'm incredibly scouse",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
@@ -254,6 +263,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
                                   dcp::HALIGN_CENTER,
                                   0.89,
                                   dcp::VALIGN_TOP,
+                                  dcp::DIRECTION_LTR,
                                   "At home it depends how I feel.\"",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
@@ -273,6 +283,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
                                   dcp::HALIGN_CENTER,
                                   0.95,
                                   dcp::VALIGN_TOP,
+                                  dcp::DIRECTION_LTR,
                                   "I spent a long weekend in Brighton",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
@@ -295,6 +306,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
                                   dcp::HALIGN_CENTER,
                                   0.89,
                                   dcp::VALIGN_TOP,
+                                  dcp::DIRECTION_RTL,
                                   "With the legendary Miss Enid Blyton",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
@@ -314,6 +326,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
                                   dcp::HALIGN_CENTER,
                                   0.95,
                                   dcp::VALIGN_TOP,
+                                  dcp::DIRECTION_TTB,
                                   "She said \"you be Noddy",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
@@ -336,6 +349,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
                                   dcp::HALIGN_CENTER,
                                   0.89,
                                   dcp::VALIGN_TOP,
+                                  dcp::DIRECTION_BTT,
                                   "That curious creature the Sphinx",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
@@ -355,6 +369,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
                                   dcp::HALIGN_CENTER,
                                   0.95,
                                   dcp::VALIGN_TOP,
+                                  dcp::DIRECTION_LTR,
                                   "Is smarter than anyone thinks",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
@@ -377,6 +392,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
                                   dcp::HALIGN_CENTER,
                                   0.89,
                                   dcp::VALIGN_TOP,
+                                  dcp::DIRECTION_LTR,
                                   "It sits there and smirks",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
@@ -396,6 +412,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
                                   dcp::HALIGN_CENTER,
                                   0.95,
                                   dcp::VALIGN_TOP,
+                                  dcp::DIRECTION_LTR,
                                   "And you don't think it works",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
@@ -418,6 +435,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
                                   dcp::HALIGN_CENTER,
                                   0.89,
                                   dcp::VALIGN_TOP,
+                                  dcp::DIRECTION_LTR,
                                   "Then when you're not looking, it winks.",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
@@ -437,6 +455,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
                                   dcp::HALIGN_CENTER,
                                   0.95,
                                   dcp::VALIGN_TOP,
+                                  dcp::DIRECTION_LTR,
                                   "When it snows you will find Sister Sledge",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
@@ -459,6 +478,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
                                   dcp::HALIGN_CENTER,
                                   0.89,
                                   dcp::VALIGN_TOP,
+                                  dcp::DIRECTION_LTR,
                                   "Out mooning, at night, on the ledge",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
@@ -478,6 +498,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
                                   dcp::HALIGN_CENTER,
                                   0.95,
                                   dcp::VALIGN_TOP,
+                                  dcp::DIRECTION_LTR,
                                   "One storey down",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
@@ -500,6 +521,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
                                   dcp::HALIGN_CENTER,
                                   0.89,
                                   dcp::VALIGN_TOP,
+                                  dcp::DIRECTION_LTR,
                                   "HELLO",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
@@ -519,6 +541,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
                                   dcp::HALIGN_CENTER,
                                   0.95,
                                   dcp::VALIGN_TOP,
+                                  dcp::DIRECTION_LTR,
                                   "WORLD",
                                   dcp::BORDER,
                                   dcp::Colour (0, 0, 0),
index 67bfcd4ec87512a309ff804c1083af2e11a2ddc1..ffd01e1f77a7394a218e2d4e89756062aff41da2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2015-2016 Carl Hetherington <cth@carlh.net>
 
     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
@@ -18,6 +18,7 @@
 */
 
 #include "interop_subtitle_asset.h"
+#include "smpte_subtitle_asset.h"
 #include "subtitle_string.h"
 #include "test.h"
 #include <boost/test/unit_test.hpp>
@@ -27,7 +28,7 @@ using std::string;
 using boost::shared_ptr;
 
 /* Write some subtitle content as Interop XML and check that it is right */
-BOOST_AUTO_TEST_CASE (write_subtitle_test)
+BOOST_AUTO_TEST_CASE (write_interop_subtitle_test)
 {
        dcp::InteropSubtitleAsset c;
        c.set_reel_number ("1");
@@ -48,6 +49,7 @@ BOOST_AUTO_TEST_CASE (write_subtitle_test)
                        dcp::HALIGN_CENTER,
                        0.8,
                        dcp::VALIGN_TOP,
+                       dcp::DIRECTION_LTR,
                        "Hello world",
                        dcp::NONE,
                        dcp::Colour (0, 0, 0),
@@ -70,6 +72,7 @@ BOOST_AUTO_TEST_CASE (write_subtitle_test)
                        dcp::HALIGN_CENTER,
                        0.4,
                        dcp::VALIGN_BOTTOM,
+                       dcp::DIRECTION_LTR,
                        "What's going on",
                        dcp::BORDER,
                        dcp::Colour (1, 2, 3),
@@ -101,3 +104,88 @@ BOOST_AUTO_TEST_CASE (write_subtitle_test)
                list<string> ()
                );
 }
+
+/* Write some subtitle content as SMPTE XML and check that it is right */
+BOOST_AUTO_TEST_CASE (write_smpte_subtitle_test)
+{
+       dcp::SMPTESubtitleAsset c;
+       c.set_reel_number (1);
+       c.set_language ("EN");
+       c.set_content_title_text ("Test");
+       c.set_issue_date (dcp::LocalTime ("2016-04-01T03:52:00+00:00"));
+
+       c.add (
+               dcp::SubtitleString (
+                       string ("Frutiger"),
+                       false,
+                       false,
+                       dcp::Colour (255, 255, 255),
+                       48,
+                       1.0,
+                       dcp::Time (0, 4,  9, 22, 24),
+                       dcp::Time (0, 4, 11, 22, 24),
+                       0,
+                       dcp::HALIGN_CENTER,
+                       0.8,
+                       dcp::VALIGN_TOP,
+                       dcp::DIRECTION_LTR,
+                       "Hello world",
+                       dcp::NONE,
+                       dcp::Colour (0, 0, 0),
+                       dcp::Time (0, 0, 0, 0, 24),
+                       dcp::Time (0, 0, 0, 0, 24)
+                       )
+               );
+
+       c.add (
+               dcp::SubtitleString (
+                       boost::optional<string> (),
+                       true,
+                       true,
+                       dcp::Colour (128, 0, 64),
+                       91,
+                       1.0,
+                       dcp::Time (5, 41,  0, 21, 24),
+                       dcp::Time (6, 12, 15, 21, 24),
+                       0,
+                       dcp::HALIGN_CENTER,
+                       0.4,
+                       dcp::VALIGN_BOTTOM,
+                       dcp::DIRECTION_RTL,
+                       "What's going on",
+                       dcp::BORDER,
+                       dcp::Colour (1, 2, 3),
+                       dcp::Time (1, 2, 3, 4, 24),
+                       dcp::Time (5, 6, 7, 8, 24)
+                       )
+               );
+
+       c._id = "a6c58cff-3e1e-4b38-acec-a42224475ef6";
+
+       check_xml (
+               c.xml_as_string (),
+               "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+               "<dcst:SubtitleReel xmlns:dcst=\"http://www.smpte-ra.org/schemas/428-7/2010/DCST\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n"
+               "  <dcst:Id>urn:uuid:a6c58cff-3e1e-4b38-acec-a42224475ef6</dcst:Id>\n"
+               "  <dcst:ContentTitleText>Test</dcst:ContentTitleText>\n"
+               "  <dcst:IssueDate>2016-04-01T03:52:00.000+00:00</dcst:IssueDate>\n"
+               "  <dcst:ReelNumber>1</dcst:ReelNumber>\n"
+               "  <dcst:Language>EN</dcst:Language>\n"
+               "  <dcst:EditRate>24 1</dcst:EditRate>\n"
+               "  <dcst:TimeCodeRate>24</dcst:TimeCodeRate>\n"
+               "  <dcst:SubtitleList>\n"
+               "    <dcst:Font ID=\"Frutiger\" Italic=\"no\" Color=\"FFFFFFFF\" Size=\"48\" Effect=\"none\" EffectColor=\"FF000000\" Script=\"normal\" Underline=\"no\" Weight=\"normal\">\n"
+               "      <dcst:Subtitle SpotNumber=\"1\" TimeIn=\"00:04:09:22\" TimeOut=\"00:04:11:22\" FadeUpTime=\"00:00:00:00\" FadeDownTime=\"00:00:00:00\">\n"
+               "        <dcst:Text Valign=\"top\" Vposition=\"80\">Hello world</dcst:Text>\n"
+               "      </dcst:Subtitle>\n"
+               "    </dcst:Font>\n"
+               "    <dcst:Font Italic=\"yes\" Color=\"FF800040\" Size=\"91\" Effect=\"border\" EffectColor=\"FF010203\" Script=\"normal\" Underline=\"no\" Weight=\"bold\">\n"
+               "      <dcst:Subtitle SpotNumber=\"2\" TimeIn=\"05:41:00:21\" TimeOut=\"06:12:15:21\" FadeUpTime=\"01:02:03:04\" FadeDownTime=\"05:06:07:08\">\n"
+               "        <dcst:Text Valign=\"bottom\" Vposition=\"40\" Direction=\"rtl\">What's going on</dcst:Text>\n"
+               "      </dcst:Subtitle>\n"
+               "    </dcst:Font>\n"
+               "  </dcst:SubtitleList>\n"
+               "</dcst:SubtitleReel>\n",
+               list<string> ()
+               );
+}
diff --git a/wscript b/wscript
index efc989aea6d2d78e254bf4fe2f6d9600fe7b6672..e2a57ed2acc235cf38cbd93f37db50c78140c42b 100644 (file)
--- a/wscript
+++ b/wscript
@@ -58,7 +58,7 @@ def configure(conf):
         conf.env.append_value('CXXFLAGS', ['-Wno-unused-result', '-Wno-unused-parameter', '-Wno-unused-local-typedef'])
 
     if conf.options.enable_openmp:
-        conf.env.append_value('CXXFLAGS', '-fopenmp')
+        conf.env.append_value('CXXFLAGS', ['-fopenmp', '-DLIBDCP_OPENMP'])
         conf.env.LIB_OPENMP = ['gomp']
 
     conf.check_cfg(package='openssl', args='--cflags --libs', uselib_store='OPENSSL', mandatory=True)