From b2ccdee3cff6ee0304c21a3e419c3210ef2061d1 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 14 Apr 2021 09:56:21 +0200 Subject: Improve handling of image subtitle IDs in XML (DoM bug #1965) When reading/writing the XML for image subtitles, we assumed that the content of the tag is just the ID of the PNG in the MXF, without any prefix. DoM bug #1965 mentions a DCP where this is not the case, and SMPTE 429-5-2009 has an example where there is urn:uuid: in the XML. This change makes DoM write this urn:uuid: prefix, and accept it if it's present (but not complain if it's not). If the urn:uuid: _is_ required in the field, it's a bit surprising that nobody has complained up to this point. Maybe nobody noticed, or nobody reported it. Cherry-picked from 098007a1ee6a46b6ff11398f94faff5c85951da4 in master. --- src/subtitle_asset.cc | 27 ++++++++++++++++++++++++--- src/subtitle_asset_internal.cc | 2 +- 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/subtitle_asset.cc b/src/subtitle_asset.cc index 083a8040..aeec99d7 100644 --- a/src/subtitle_asset.cc +++ b/src/subtitle_asset.cc @@ -385,13 +385,33 @@ SubtitleAsset::maybe_add_subtitle (string text, list const & parse_s ) ); break; - case ParseState::IMAGE: + case ParseState::Type::IMAGE: + { + switch (standard) { + case INTEROP: + if (text.size() >= 4) { + /* Remove file extension */ + text = text.substr(0, text.size() - 4); + } + break; + case SMPTE: + /* It looks like this urn:uuid: is required, but DoM wasn't expecting it (and not writing it) + * until around 2.15.140 so I guess either: + * a) it is not (always) used in the field, or + * b) nobody noticed / complained. + */ + if (text.substr(0, 9) == "urn:uuid:") { + text = text.substr(9); + } + break; + } + /* Add a subtitle with no image data and we'll fill that in later */ _subtitles.push_back ( shared_ptr ( new SubtitleImage ( - Data (), - standard == INTEROP ? text.substr(0, text.size() - 4) : text, + Data(), + text, ps.in.get(), ps.out.get(), ps.h_position.get_value_or(0), @@ -405,6 +425,7 @@ SubtitleAsset::maybe_add_subtitle (string text, list const & parse_s ); break; } + } } list > diff --git a/src/subtitle_asset_internal.cc b/src/subtitle_asset_internal.cc index 7b9e18e9..25e03f0b 100644 --- a/src/subtitle_asset_internal.cc +++ b/src/subtitle_asset_internal.cc @@ -239,7 +239,7 @@ order::Image::as_xml (xmlpp::Element* parent, Context& context) const position_align (e, context, _h_align, _h_position, _v_align, _v_position); if (context.standard == SMPTE) { - e->add_child_text (_id); + e->add_child_text ("urn:uuid:" + _id); } else { e->add_child_text (_id + ".png"); } -- cgit v1.2.3