diff --git a/include/bmx/mxf_op1a/OP1AIndexTable.h b/include/bmx/mxf_op1a/OP1AIndexTable.h index 82c7857a..4a4b975e 100644 --- a/include/bmx/mxf_op1a/OP1AIndexTable.h +++ b/include/bmx/mxf_op1a/OP1AIndexTable.h @@ -193,7 +193,8 @@ class OP1AIndexTable void UpdateIndex(uint32_t size, uint32_t num_samples); public: - bool HaveWrittenCBE() const { return mHaveWrittenCBE; } + bool HaveWrittenCBE() const { return mIsCBE && mHaveWritten; } + bool HaveWritten() const { return mHaveWritten; } bool HaveSegments(); bool HaveFooterSegments(); @@ -243,7 +244,7 @@ class OP1AIndexTable int64_t mStreamOffset; std::vector mWrittenVBEIndexSegments; - bool mHaveWrittenCBE; + bool mHaveWritten; }; diff --git a/src/mxf_op1a/OP1AFile.cpp b/src/mxf_op1a/OP1AFile.cpp index dbcebf95..58d77a14 100644 --- a/src/mxf_op1a/OP1AFile.cpp +++ b/src/mxf_op1a/OP1AFile.cpp @@ -524,12 +524,14 @@ void OP1AFile::CompleteWrite() mMXFFile->openMemoryFile(MEMORY_WRITE_CHUNK_SIZE); - // non-minimal partition flavour: write any remaining VBE index segments or follow CBE index segments + // write any remaining VBE index segments or follow CBE index segments if (HAVE_PRIMARY_EC && !(mFlavour & OP1A_MIN_PARTITIONS_FLAVOUR) && + (!(mFlavour & OP1A_BODY_PARTITIONS_FLAVOUR) || + (mIndexTable->RepeatIndexTable() && mIndexTable->HaveWritten())) && ((mIndexTable->IsVBE() && mIndexTable->HaveSegments()) || - (mIndexTable->IsCBE() && !mIndexTable->HaveWrittenCBE() && mIndexTable->GetDuration() > 0))) + (mIndexTable->IsCBE() && !mIndexTable->HaveWritten() && mIndexTable->GetDuration() > 0))) { Partition &index_partition = mMXFFile->createPartition(); index_partition.setKey(&MXF_PP_K(ClosedComplete, Body)); // will be complete when memory flushed @@ -577,7 +579,7 @@ void OP1AFile::CompleteWrite() // minimal/body partitions flavour: write any remaining index segments if (HAVE_PRIMARY_EC && mIndexTable->HaveFooterSegments()) { - if (mIndexTable->IsCBE() && !mIndexTable->HaveWrittenCBE()) { + if (mIndexTable->IsCBE() && !mIndexTable->HaveWritten()) { // CBE index table that is not a repeat mCBEIndexPartitionIndex = mMXFFile->getPartitions().size() - 1; } diff --git a/src/mxf_op1a/OP1AIndexTable.cpp b/src/mxf_op1a/OP1AIndexTable.cpp index eaa0a9e4..84fd3e3b 100644 --- a/src/mxf_op1a/OP1AIndexTable.cpp +++ b/src/mxf_op1a/OP1AIndexTable.cpp @@ -300,7 +300,7 @@ OP1AIndexTable::OP1AIndexTable(uint32_t index_sid, uint32_t body_sid, mxfRationa mAVCIFirstIndexSegment = 0; mDuration = 0; mStreamOffset = 0; - mHaveWrittenCBE = false; + mHaveWritten = false; } OP1AIndexTable::~OP1AIndexTable() @@ -541,7 +541,7 @@ bool OP1AIndexTable::HaveSegments() bool OP1AIndexTable::HaveFooterSegments() { if (mIsCBE) - return mDuration > 0 && (!mHaveWrittenCBE || mRepeatIndexTable); + return mDuration > 0 && (!mHaveWritten || mRepeatIndexTable); else return HaveSegments() || (!mWrittenVBEIndexSegments.empty() && mRepeatIndexTable); } @@ -560,9 +560,8 @@ void OP1AIndexTable::WriteSegments(File *mxf_file, Partition *partition, bool fi } partition->markIndexEnd(mxf_file); - if (mIsCBE) { - mHaveWrittenCBE = true; - } else { + mHaveWritten = true; + if (!mIsCBE) { if (!partition->isFooter() && mRepeatIndexTable) { size_t i; for (i = 0; i < mIndexSegments.size(); i++) diff --git a/test/mxf_op1a/index_follows_1.md5 b/test/mxf_op1a/index_follows_1.md5 index f41f2406..97c27bc5 100644 --- a/test/mxf_op1a/index_follows_1.md5 +++ b/test/mxf_op1a/index_follows_1.md5 @@ -1 +1 @@ -ee3d6981614538f9a2d3e4195f7d1d2f \ No newline at end of file +d990fca91ecc74c9e12ee801a563c02b \ No newline at end of file diff --git a/test/mxf_op1a/index_follows_2.md5 b/test/mxf_op1a/index_follows_2.md5 index 7ca4b404..05cda49e 100644 --- a/test/mxf_op1a/index_follows_2.md5 +++ b/test/mxf_op1a/index_follows_2.md5 @@ -1 +1 @@ -d2bd65039ccd59595eb8da9b6324c038 \ No newline at end of file +3f26e93f899bfe454f41226d0d4faf3a \ No newline at end of file diff --git a/test/mxf_op1a/index_follows_3.md5 b/test/mxf_op1a/index_follows_3.md5 index f41f2406..ef8dd6e9 100644 --- a/test/mxf_op1a/index_follows_3.md5 +++ b/test/mxf_op1a/index_follows_3.md5 @@ -1 +1 @@ -ee3d6981614538f9a2d3e4195f7d1d2f \ No newline at end of file +73eea14e07de444a6f9be8a60c7a25d0 \ No newline at end of file diff --git a/test/mxf_op1a/index_follows_4.md5 b/test/mxf_op1a/index_follows_4.md5 index 0577b3bf..388e8684 100644 --- a/test/mxf_op1a/index_follows_4.md5 +++ b/test/mxf_op1a/index_follows_4.md5 @@ -1 +1 @@ -5536a39e8a0b4ad9df369192ecc763fb \ No newline at end of file +868f576736fad1be3d9d19f07775a858 \ No newline at end of file diff --git a/test/mxf_op1a/index_follows_5.md5 b/test/mxf_op1a/index_follows_5.md5 index 0577b3bf..ef8dd6e9 100644 --- a/test/mxf_op1a/index_follows_5.md5 +++ b/test/mxf_op1a/index_follows_5.md5 @@ -1 +1 @@ -5536a39e8a0b4ad9df369192ecc763fb \ No newline at end of file +73eea14e07de444a6f9be8a60c7a25d0 \ No newline at end of file diff --git a/test/mxf_op1a/index_follows_6.md5 b/test/mxf_op1a/index_follows_6.md5 new file mode 100644 index 00000000..b1f6a1a2 --- /dev/null +++ b/test/mxf_op1a/index_follows_6.md5 @@ -0,0 +1 @@ +aa160bdf9c305623a921373bf9afc06a \ No newline at end of file diff --git a/test/mxf_op1a/index_follows_7.md5 b/test/mxf_op1a/index_follows_7.md5 new file mode 100644 index 00000000..3e5a2e86 --- /dev/null +++ b/test/mxf_op1a/index_follows_7.md5 @@ -0,0 +1 @@ +13d9d50ce342c5cb9685436ca2a10c1a \ No newline at end of file diff --git a/test/mxf_op1a/test_indexfollows.cmake b/test/mxf_op1a/test_indexfollows.cmake index d07dcca6..43d8de6e 100644 --- a/test/mxf_op1a/test_indexfollows.cmake +++ b/test/mxf_op1a/test_indexfollows.cmake @@ -9,6 +9,8 @@ if(TEST_MODE STREQUAL "check") set(output_file_3 test_index_follows_3.mxf) set(output_file_4 test_index_follows_4.mxf) set(output_file_5 test_index_follows_5.mxf) + set(output_file_6 test_index_follows_6.mxf) + set(output_file_7 test_index_follows_7.mxf) elseif(TEST_MODE STREQUAL "samples") file(MAKE_DIRECTORY ${BMX_TEST_SAMPLES_DIR}) @@ -17,23 +19,27 @@ elseif(TEST_MODE STREQUAL "samples") set(output_file_3 ${BMX_TEST_SAMPLES_DIR}/test_index_follows_3.mxf) set(output_file_4 ${BMX_TEST_SAMPLES_DIR}/test_index_follows_4.mxf) set(output_file_5 ${BMX_TEST_SAMPLES_DIR}/test_index_follows_5.mxf) + set(output_file_6 ${BMX_TEST_SAMPLES_DIR}/test_index_follows_6.mxf) + set(output_file_7 ${BMX_TEST_SAMPLES_DIR}/test_index_follows_7.mxf) else() set(output_file_1 test_index_follows_1.mxf) set(output_file_2 test_index_follows_2.mxf) set(output_file_3 test_index_follows_3.mxf) set(output_file_4 test_index_follows_4.mxf) set(output_file_5 test_index_follows_5.mxf) + set(output_file_6 test_index_follows_6.mxf) + set(output_file_7 test_index_follows_7.mxf) endif() set(create_test_audio ${CREATE_TEST_ESSENCE} -t 1 - -d 3 + -d 24 audio_index_follows ) set(create_test_video ${CREATE_TEST_ESSENCE} - -t 7 - -d 3 + -t 14 + -d 24 video_index_follows ) @@ -44,6 +50,8 @@ set(tests "--body-part" "--repeat-index" "--body-part\;--repeat-index" + "--part\;12\;--body-part" + "--part\;12\;--body-part\;--repeat-index" ) list(LENGTH tests num_tests) @@ -71,7 +79,7 @@ foreach(index RANGE 1 ${max_index}) -o ${output_file_${index}} --index-follows ${add_opt} - --avci100_1080i video_index_follows + --mpeg2lg_422p_hl_1080i video_index_follows -q 16 --pcm audio_index_follows )