Increase header size when writing SMPTE subtitle MXFs; fixes problems when writing... v1.6.8
authorCarl Hetherington <cth@carlh.net>
Tue, 21 May 2019 20:23:55 +0000 (21:23 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 21 May 2019 20:24:30 +0000 (21:24 +0100)
This is a backport of b7c7e14463d91608b080a5a63fcfb4d330ced863 from master.

src/smpte_subtitle_asset.cc

index ae473071c84d6a281e2aa1244912ca38cd1be234..27f486da3bd3a9532bd7d8a0d7475872f3611981 100644 (file)
@@ -393,7 +393,10 @@ SMPTESubtitleAsset::write (boost::filesystem::path p) const
        descriptor.ContainerDuration = _intrinsic_duration;
 
        ASDCP::TimedText::MXFWriter writer;
-       ASDCP::Result_t r = writer.OpenWrite (p.string().c_str(), writer_info, descriptor);
+       /* This header size is a guess.  Empirically it seems that each subtitle reference is 90 bytes, and we need some extra.
+          The defualt size is not enough for some feature-length PNG sub projects (see DCP-o-matic #1561).
+       */
+       ASDCP::Result_t r = writer.OpenWrite (p.string().c_str(), writer_info, descriptor, _subtitles.size() * 90 + 16384);
        if (ASDCP_FAILURE (r)) {
                boost::throw_exception (FileError ("could not open subtitle MXF for writing", p.string(), r));
        }