Skip to content

Commit

Permalink
Merge pull request #118 from msheby/feature/reuse-mca-soundfield
Browse files Browse the repository at this point in the history
feature: reuse MCA soundfield
  • Loading branch information
jhursty authored Dec 12, 2023
2 parents 029917a + 5c60795 commit 61adae1
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions src/MXF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1676,11 +1676,15 @@ bool
ASDCP::MXF::decode_mca_string(const std::string& s, const mca_label_map_t& labels, const Dictionary* dict, const std::string& language,
InterchangeObject_list_t& descriptor_list, ui32_t& channel_count)
{
typedef std::map<const std::string, ASDCP::MXF::SoundfieldGroupLabelSubDescriptor *, ci_comp> sfg_map_t;
std::string symbol_buf;
std::string current_language;
channel_count = 0;
ASDCP::MXF::SoundfieldGroupLabelSubDescriptor *current_soundfield = 0, *prev_soundfield = 0;
std::string::const_iterator i;
sfg_map_t used_soundfields; /* Track old soundfields, so that they can be reused. This allows
for the following type of layout:
71(L,R,C,LFE,Lss,Rss),HI,VIN,-,-,71(Lrs,Rrs),DBOX,- */

for ( i = s.begin(); i != s.end(); ++i )
{
Expand Down Expand Up @@ -1725,15 +1729,23 @@ ASDCP::MXF::decode_mca_string(const std::string& s, const mca_label_map_t& label
return false;
}

current_soundfield = new ASDCP::MXF::SoundfieldGroupLabelSubDescriptor(dict);
GenRandomValue(current_soundfield->MCALinkID);

current_soundfield->MCATagSymbol = (i->second.requires_prefix ? "sg" : "") + i->first;
current_soundfield->MCATagName = i->second.tag_name;
current_soundfield->RFC5646SpokenLanguage = language;
current_soundfield->MCALabelDictionaryID = i->second.ul;
descriptor_list.push_back(reinterpret_cast<ASDCP::MXF::InterchangeObject*>(current_soundfield));
prev_soundfield = current_soundfield;
sfg_map_t::const_iterator ui = used_soundfields.find(symbol_buf);
if ( ui != used_soundfields.end() )
{
current_soundfield = ui->second; // reuse the old soundfield.
}
else
{
current_soundfield = new ASDCP::MXF::SoundfieldGroupLabelSubDescriptor(dict);
GenRandomValue(current_soundfield->MCALinkID);

current_soundfield->MCATagSymbol = (i->second.requires_prefix ? "sg" : "") + i->first;
current_soundfield->MCATagName = i->second.tag_name;
current_soundfield->RFC5646SpokenLanguage = language;
current_soundfield->MCALabelDictionaryID = i->second.ul;
descriptor_list.push_back(reinterpret_cast<ASDCP::MXF::InterchangeObject*>(current_soundfield));
prev_soundfield = current_soundfield;
}
symbol_buf.clear();
}
else if ( *i == ')' )
Expand Down

0 comments on commit 61adae1

Please sign in to comment.