void AvidMJPEGTrack::WriteVBEIndexTable(Partition *partition) { KAGFillerWriter kag_filler_writer(partition); partition->markIndexStart(mMXFFile); IndexTableSegment segment; segment.setIndexEditRate(mDescriptorHelper->GetSampleRate()); segment.setIndexSID(mIndexSID); segment.setBodySID(mBodySID); segment.setEditUnitByteCount(0); uint32_t num_index_entries = mIndexSegment.GetSize() / INDEX_ENTRY_SIZE; BMX_ASSERT(num_index_entries >= 1); int64_t index_duration = num_index_entries - 1; mxfUUID uuid; mxf_generate_uuid(&uuid); segment.setInstanceUID(uuid); segment.setIndexStartPosition(0); segment.setIndexDuration(index_duration); segment.writeHeader(mMXFFile, 0, num_index_entries); // Avid ignores the 16-bit llen and uses the number of index entries (uint32) instead segment.writeAvidIndexEntryArrayHeader(mMXFFile, 0, 0, num_index_entries); mMXFFile->write(mIndexSegment.GetBytes(), mIndexSegment.GetSize()); kag_filler_writer.write(mMXFFile); partition->markIndexEnd(mMXFFile); }
void RDD9IndexTable::WriteVBESegments(File *mxf_file, vector<RDD9IndexTableSegment*> &segments) { size_t i; for (i = 0; i < segments.size(); i++) { IndexTableSegment *segment = segments[i]->GetSegment(); ByteArray *entries = segments[i]->GetEntries(); mxfUUID uuid; mxf_generate_uuid(&uuid); segment->setInstanceUID(uuid); // Note: RDD9 states that PosTableCount is not encoded but mxf_write_index_table_segment will write it with // the default value 0 segment->writeHeader(mxf_file, (uint32_t)mDeltaEntries.size(), (uint32_t)segment->getIndexDuration()); if (!mDeltaEntries.empty()) { segment->writeDeltaEntryArrayHeader(mxf_file, (uint32_t)mDeltaEntries.size()); size_t j; for (j = 0; j < mDeltaEntries.size(); j++) { segment->writeDeltaEntry(mxf_file, mDeltaEntries[j].pos_table_index, mDeltaEntries[j].slice, mDeltaEntries[j].element_delta); } } segment->writeIndexEntryArrayHeader(mxf_file, mSliceCount, 0, (uint32_t)segment->getIndexDuration()); mxf_file->write(entries->GetBytes(), entries->GetSize()); } }
void AS02MPEG2LGTrack::WriteVBEIndexTable(Partition *partition) { if (mIndexSegments.empty()) return; partition->markIndexStart(mMXFFile); IndexTableSegment segment; segment.setIndexEditRate(mDescriptorHelper->GetSampleRate()); segment.setIndexSID(mIndexSID); segment.setBodySID(mBodySID); segment.setEditUnitByteCount(0); int64_t index_start_position = mIndexStartPosition; uint32_t index_duration; mxfUUID uuid; size_t i; for (i = 0; i < mIndexSegments.size(); i++) { index_duration = mIndexSegments[i]->GetSize() / INDEX_ENTRY_SIZE; mxf_generate_uuid(&uuid); segment.setInstanceUID(uuid); segment.setIndexStartPosition(index_start_position); segment.setIndexDuration(index_duration); segment.writeHeader(mMXFFile, 1, index_duration); segment.writeDeltaEntryArrayHeader(mMXFFile, 1); segment.writeDeltaEntry(mMXFFile, -1, 0, 0); segment.writeIndexEntryArrayHeader(mMXFFile, 0, 0, index_duration); mMXFFile->write(mIndexSegments[i]->GetBytes(), mIndexSegments[i]->GetSize()); delete mIndexSegments[i]; index_start_position += index_duration; } mIndexSegments.clear(); mIndexStartPosition = index_start_position; partition->fillToKag(mMXFFile); partition->markIndexEnd(mMXFFile); }