X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fsubtitle_content.cc;h=5b3b453b6eaf12d7614c0a3b6beb2f2b87da3bdb;hb=a8a0dfd1b21de6c0facf965ab119833ff6f790bf;hp=89953b0e5d5c791c1db7fcd2aa94aff61fa6c3a1;hpb=cc76b517f6a74f813ae38137bdc88ff3bafa6dd9;p=dcpomatic.git diff --git a/src/lib/subtitle_content.cc b/src/lib/subtitle_content.cc index 89953b0e5..5b3b453b6 100644 --- a/src/lib/subtitle_content.cc +++ b/src/lib/subtitle_content.cc @@ -1,19 +1,20 @@ /* Copyright (C) 2013-2016 Carl Hetherington - This program is free software; you can redistribute it and/or modify + This file is part of DCP-o-matic. + + DCP-o-matic 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, + DCP-o-matic 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. + along with DCP-o-matic. If not, see . */ @@ -24,7 +25,6 @@ #include "font.h" #include "raw_convert.h" #include "content.h" -#include "film.h" #include #include #include @@ -51,8 +51,8 @@ int const SubtitleContentProperty::COLOUR = 508; int const SubtitleContentProperty::OUTLINE = 509; int const SubtitleContentProperty::OUTLINE_COLOUR = 510; -SubtitleContent::SubtitleContent (Content* parent, shared_ptr film) - : ContentPart (parent, film) +SubtitleContent::SubtitleContent (Content* parent) + : ContentPart (parent) , _use (false) , _burn (false) , _x_offset (0) @@ -67,17 +67,28 @@ SubtitleContent::SubtitleContent (Content* parent, shared_ptr film) } shared_ptr -SubtitleContent::from_xml (Content* parent, shared_ptr film, cxml::ConstNodePtr node, int version) +SubtitleContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version) { + if (version < 34) { + /* With old metadata FFmpeg content has the subtitle-related tags even with no + subtitle streams, so check for that. + */ + if (node->string_child("Type") == "FFmpeg" && node->node_children("SubtitleStream").empty()) { + return shared_ptr (); + } + + /* Otherwise we can drop through to the newer logic */ + } + if (!node->optional_number_child("SubtitleXOffset") && !node->optional_number_child("SubtitleOffset")) { return shared_ptr (); } - return shared_ptr (new SubtitleContent (parent, film, node, version)); + return shared_ptr (new SubtitleContent (parent, node, version)); } -SubtitleContent::SubtitleContent (Content* parent, shared_ptr film, cxml::ConstNodePtr node, int version) - : ContentPart (parent, film) +SubtitleContent::SubtitleContent (Content* parent, cxml::ConstNodePtr node, int version) + : ContentPart (parent) , _use (false) , _burn (false) , _x_offset (0) @@ -125,8 +136,8 @@ SubtitleContent::SubtitleContent (Content* parent, shared_ptr film, connect_to_fonts (); } -SubtitleContent::SubtitleContent (Content* parent, shared_ptr film, vector > c) - : ContentPart (parent, film) +SubtitleContent::SubtitleContent (Content* parent, vector > c) + : ContentPart (parent) { shared_ptr ref = c[0]->subtitle; DCPOMATIC_ASSERT (ref);