diff options
| author | John Hurst <jhurst@cinecert.com> | 2021-04-08 16:52:51 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-08 16:52:51 -0700 |
| commit | 4e0891ab9ee94b822043126ea07e97641015e9b7 (patch) | |
| tree | 1bb4af6903d3ca4a2d46771d1b8215a229bad602 /src/AS_DCP_TimedText.cpp | |
| parent | 162d9b61ac45adc55e21950624bc921dea816aa3 (diff) | |
| parent | 5eb05375a501f2f4a899939e431fdae335917bab (diff) | |
Merge pull request #77 from dcbullock/issues/0076-dcp-tt-many-png-wrap
Increase header buffer size when wrapping 428-7.
Diffstat (limited to 'src/AS_DCP_TimedText.cpp')
| -rw-r--r-- | src/AS_DCP_TimedText.cpp | 82 |
1 files changed, 80 insertions, 2 deletions
diff --git a/src/AS_DCP_TimedText.cpp b/src/AS_DCP_TimedText.cpp index f19f6fc..3bea4e3 100644 --- a/src/AS_DCP_TimedText.cpp +++ b/src/AS_DCP_TimedText.cpp @@ -518,8 +518,39 @@ ASDCP::TimedText::MXFWriter::h__Writer::SetSourceStream(ASDCP::TimedText::TimedT ResourceList_t::const_iterator ri; Result_t result = TimedText_TDesc_to_MD(m_TDesc); + /* st0429-5-2017 limitation: the maximum number of sub-descriptors + is limited by the maximum length of the sub-descriptor array + contained in the timed text descriptor in the MXF header + + catch it here for operator messages + + max bytes 65536 + + 8 - array len + array item size + 16*n - 16 * number of sub-descriptors + + max sub-descriptors is 4095 + (4095*16) + 8 = 65258 + (4096*16) + 8 = 65544 + */ + int resource_available = 4095; + + /* this method will grow the requested header buffer, m_HeaderSize, + to accommodate the space needed for the timed text subdescriptors + + m_HeaderSize is already set to something, but the default of 16384 + is not enough for large sets of PNG subtitles + */ + + bool sd_array_init = false; for ( ri = m_TDesc.ResourceList.begin() ; ri != m_TDesc.ResourceList.end() && ASDCP_SUCCESS(result); ri++ ) { + if (! resource_available--) + { + DefaultLogSink().Error("Exceeded allowed SMPTE ST 429-5 resources.\n"); + return RESULT_FORMAT; + } + TimedTextResourceSubDescriptor* resourceSubdescriptor = new TimedTextResourceSubDescriptor(m_Dict); GenRandomValue(resourceSubdescriptor->InstanceUID); resourceSubdescriptor->AncillaryResourceID.Set((*ri).ResourceID); @@ -528,8 +559,55 @@ ASDCP::TimedText::MXFWriter::h__Writer::SetSourceStream(ASDCP::TimedText::TimedT m_EssenceSubDescriptorList.push_back((FileDescriptor*)resourceSubdescriptor); m_EssenceDescriptor->SubDescriptors.push_back(resourceSubdescriptor->InstanceUID); - // 72 == sizeof K, L, instanceuid, uuid + sizeof int32 + tag/len * 4 - m_HeaderSize += ( resourceSubdescriptor->MIMEMediaType.ArchiveLength() * 2 /*ArchiveLength is broken*/ ) + 72; + /* the first subdescriptor requires 12 bytes to initialize + the sub-descriptor UUID array + + 4 - tag/len + 4 - item count + 4 - each item len + ---- + 12 - total + + */ + if ( ! sd_array_init ) + { + sd_array_init = true; + m_HeaderSize += 12; + } + + + /* each subdescriptor requires 88 bytes + MIMEMediaType.archiveLength() + of extra header space + + TimedTextDescriptor (array of sub-descriptors) + 16 - uuid in the TimedTextDescriptor sub-descriptor array + + TimedTextSubDescriptor + 16 - key + 4 - len (fixed 4 byte long length type) + 4 - tag/len + 16 - instance uuid + 4 - tag/len + 16 - ancillary resource uuid + 4 - tag/len + n - MIMEMediaType UTF16 length + 4 - tag/len + 4 - id + -------------- + 88+n - total + + */ + + /* MIMEMediaType.ArchiveLength: + - includes sizeof(ui32_t) for an internal length representation + - returns half of what it should for UTF16 representation of + pure ASCII bytes + - ( MXFTypes.h UTF16String::ArchiveLength ) + + fix up the return value before using it + */ + int n = (resourceSubdescriptor->MIMEMediaType.ArchiveLength() - sizeof(ui32_t)) * 2; + m_HeaderSize += (88 + n); } m_EssenceStreamID = 10; |
