From 0dfba123cbfe59395c894af6acb1e49801bd9c26 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 8 Sep 2012 22:05:48 +0100 Subject: [PATCH] Ignore Language tag in subtitles. Get MXF/XML filenames from the asset map. --- src/asset_map.cc | 12 ++++++++++++ src/asset_map.h | 2 ++ src/cpl.cc | 1 + src/dcp.cc | 32 ++++++-------------------------- src/pkl.cc | 13 ------------- src/pkl.h | 2 -- test/ref/info.log | 5 +++++ 7 files changed, 26 insertions(+), 41 deletions(-) diff --git a/src/asset_map.cc b/src/asset_map.cc index 3af2d6f8..31809c9b 100644 --- a/src/asset_map.cc +++ b/src/asset_map.cc @@ -24,6 +24,7 @@ #include "asset_map.h" using namespace std; +using namespace boost; using namespace libdcp; AssetMap::AssetMap (string file) @@ -54,3 +55,14 @@ Chunk::Chunk (xmlpp::Node const * node) length = optional_int64_node ("Length"); } +shared_ptr +AssetMap::asset_from_id (string id) const +{ + for (list >::const_iterator i = assets.begin (); i != assets.end(); ++i) { + if ((*i)->id == id) { + return *i; + } + } + + return shared_ptr (); +} diff --git a/src/asset_map.h b/src/asset_map.h index 430cb5aa..10a0915f 100644 --- a/src/asset_map.h +++ b/src/asset_map.h @@ -55,6 +55,8 @@ class AssetMap : public XMLFile public: AssetMap (std::string file); + boost::shared_ptr asset_from_id (std::string id) const; + std::string id; std::string creator; int64_t volume_count; diff --git a/src/cpl.cc b/src/cpl.cc index 93deedf8..c135db3c 100644 --- a/src/cpl.cc +++ b/src/cpl.cc @@ -142,6 +142,7 @@ MainSubtitle::MainSubtitle (xmlpp::Node const * node) duration = int64_node ("Duration"); ignore_node ("Hash"); + ignore_node ("Language"); done (); } diff --git a/src/dcp.cc b/src/dcp.cc index d9604bef..29479481 100644 --- a/src/dcp.cc +++ b/src/dcp.cc @@ -332,15 +332,10 @@ DCP::DCP (string directory, bool require_mxfs) if ((*i)->asset_list->main_picture) { - string n = pkl->asset_from_id (p->id)->original_file_name; - if (n.empty ()) { - n = p->annotation_text; - } - try { picture.reset (new MonoPictureAsset ( _directory, - n, + asset_map->asset_from_id ((*i)->asset_list->main_picture->id)->chunks.front()->path, _fps, (*i)->asset_list->main_picture->entry_point, (*i)->asset_list->main_picture->duration @@ -354,15 +349,10 @@ DCP::DCP (string directory, bool require_mxfs) } else if ((*i)->asset_list->main_stereoscopic_picture) { - string n = pkl->asset_from_id (p->id)->original_file_name; - if (n.empty ()) { - n = p->annotation_text; - } - try { picture.reset (new StereoPictureAsset ( _directory, - n, + asset_map->asset_from_id ((*i)->asset_list->main_stereoscopic_picture->id)->chunks.front()->path, _fps, (*i)->asset_list->main_stereoscopic_picture->entry_point, (*i)->asset_list->main_stereoscopic_picture->duration @@ -378,15 +368,10 @@ DCP::DCP (string directory, bool require_mxfs) if ((*i)->asset_list->main_sound) { - string n = pkl->asset_from_id ((*i)->asset_list->main_sound->id)->original_file_name; - if (n.empty ()) { - n = (*i)->asset_list->main_sound->annotation_text; - } - try { sound.reset (new SoundAsset ( _directory, - n, + asset_map->asset_from_id ((*i)->asset_list->main_sound->id)->chunks.front()->path, _fps, (*i)->asset_list->main_sound->entry_point, (*i)->asset_list->main_sound->duration @@ -400,16 +385,11 @@ DCP::DCP (string directory, bool require_mxfs) } if ((*i)->asset_list->main_subtitle) { - - string n = pkl->asset_from_id ((*i)->asset_list->main_subtitle->id)->original_file_name; - if (n.empty ()) { - n = (*i)->asset_list->main_subtitle->annotation_text; - } subtitle.reset (new SubtitleAsset ( - _directory, - n - ) + _directory, + asset_map->asset_from_id ((*i)->asset_list->main_subtitle->id)->chunks.front()->path + ) ); } diff --git a/src/pkl.cc b/src/pkl.cc index 51e75818..41c44734 100644 --- a/src/pkl.cc +++ b/src/pkl.cc @@ -49,16 +49,3 @@ PKLAsset::PKLAsset (xmlpp::Node const * node) type = string_node ("Type"); original_file_name = optional_string_node ("OriginalFileName"); } - -shared_ptr -PKL::asset_from_id (string id) const -{ - for (list >::const_iterator i = assets.begin (); i != assets.end(); ++i) { - if ((*i)->id == id) { - return *i; - } - } - - return shared_ptr (); -} - diff --git a/src/pkl.h b/src/pkl.h index ed1bcd61..a0a8cb75 100644 --- a/src/pkl.h +++ b/src/pkl.h @@ -45,8 +45,6 @@ class PKL : public XMLFile public: PKL (std::string file); - boost::shared_ptr asset_from_id (std::string id) const; - std::string id; std::string annotation_text; std::string issue_date; diff --git a/test/ref/info.log b/test/ref/info.log index 8f14a881..ba0c9991 100644 --- a/test/ref/info.log +++ b/test/ref/info.log @@ -26,6 +26,11 @@ DCP: ../libdcp-test/BARBARA_TLR_F_DE-FR_CH_51_2K_LOK_20120410_OV Frames per second: 24 Reel 1 Subtitle: 31 subtitles in French +DCP: ../libdcp-test/MACHINE-GUN-PREACH_TLR-1_F_EN-de-fr_CH_51_2K_TIT_20111107 + Length: 3513 + Frames per second: 24 +Reel 1 + Subtitle: 94 subtitles in English DCP: ../libdcp-test/ASTERIX_TLR-01_F_FR-DE_CH_51_2K_FRE_20120730_DGL_OV Length: 3080 Frames per second: 24 -- 2.30.2