diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-07-09 02:30:18 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-07-09 02:30:18 +0100 |
| commit | 7bb241e6857f5f3614fd3b8722d545e85a6b6316 (patch) | |
| tree | 9d90112ec5f380560d9cc44db1503c0083d6f996 /src | |
| parent | 5da3dca64c9d0398a5507688a230f4a9bf7dc9cb (diff) | |
Basic reading of Interop/SMPTE image subtitles with a test for Interop.
Diffstat (limited to 'src')
| -rw-r--r-- | src/interop_subtitle_asset.cc | 7 | ||||
| -rw-r--r-- | src/smpte_subtitle_asset.cc | 36 | ||||
| -rw-r--r-- | src/subtitle_image.h | 4 |
3 files changed, 36 insertions, 11 deletions
diff --git a/src/interop_subtitle_asset.cc b/src/interop_subtitle_asset.cc index 1cd99563..e2873fb6 100644 --- a/src/interop_subtitle_asset.cc +++ b/src/interop_subtitle_asset.cc @@ -80,7 +80,12 @@ InteropSubtitleAsset::InteropSubtitleAsset (boost::filesystem::path file) } } - /* XXX: now find SubtitleImages in _subtitles and load their PNG */ + BOOST_FOREACH (shared_ptr<Subtitle> i, _subtitles) { + shared_ptr<SubtitleImage> si = dynamic_pointer_cast<SubtitleImage>(i); + if (si) { + si->set_png_image (Data (file.parent_path() / String::compose("%1.png", si->id()))); + } + } } InteropSubtitleAsset::InteropSubtitleAsset () diff --git a/src/smpte_subtitle_asset.cc b/src/smpte_subtitle_asset.cc index 91afec14..b568139a 100644 --- a/src/smpte_subtitle_asset.cc +++ b/src/smpte_subtitle_asset.cc @@ -173,17 +173,19 @@ SMPTESubtitleAsset::read_mxf_descriptor (shared_ptr<ASDCP::TimedText::MXFReader> i != descriptor.ResourceList.end(); ++i) { - if (i->Type == ASDCP::TimedText::MT_OPENTYPE) { - ASDCP::TimedText::FrameBuffer buffer; - buffer.Capacity (10 * 1024 * 1024); - reader->ReadAncillaryResource (i->ResourceID, buffer, dec->context(), dec->hmac()); + ASDCP::TimedText::FrameBuffer buffer; + buffer.Capacity (10 * 1024 * 1024); + reader->ReadAncillaryResource (i->ResourceID, buffer, dec->context(), dec->hmac()); - char id[64]; - Kumu::bin2UUIDhex (i->ResourceID, ASDCP::UUIDlen, id, sizeof (id)); + char id[64]; + Kumu::bin2UUIDhex (i->ResourceID, ASDCP::UUIDlen, id, sizeof (id)); - shared_array<uint8_t> data (new uint8_t[buffer.Size()]); - memcpy (data.get(), buffer.RoData(), buffer.Size()); + shared_array<uint8_t> data (new uint8_t[buffer.Size()]); + memcpy (data.get(), buffer.RoData(), buffer.Size()); + switch (i->Type) { + case ASDCP::TimedText::MT_OPENTYPE: + { list<shared_ptr<SMPTELoadFontNode> >::const_iterator j = _load_font_nodes.begin (); while (j != _load_font_nodes.end() && (*j)->urn != id) { ++j; @@ -192,10 +194,24 @@ SMPTESubtitleAsset::read_mxf_descriptor (shared_ptr<ASDCP::TimedText::MXFReader> if (j != _load_font_nodes.end ()) { _fonts.push_back (Font ((*j)->id, (*j)->urn, Data (data, buffer.Size ()))); } + break; } - } + case ASDCP::TimedText::MT_PNG: + { + list<shared_ptr<Subtitle> >::const_iterator j = _subtitles.begin (); + while (j != _subtitles.end() && ((!dynamic_pointer_cast<SubtitleImage>(*j)) || dynamic_pointer_cast<SubtitleImage>(*j)->id() != id)) { + ++j; + } - /* XXX: load PNG and attach them to _subtitles */ + if (j != _subtitles.end()) { + dynamic_pointer_cast<SubtitleImage>(*j)->set_png_image (Data(data, buffer.Size())); + } + break; + } + default: + break; + } + } /* Get intrinsic duration */ _intrinsic_duration = descriptor.ContainerDuration; diff --git a/src/subtitle_image.h b/src/subtitle_image.h index c398ef78..062df56b 100644 --- a/src/subtitle_image.h +++ b/src/subtitle_image.h @@ -82,6 +82,10 @@ public: return _png_image; } + void set_png_image (Data d) { + _png_image = d; + } + std::string id () const { return _id; } |
