Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For body part, place last index table segment in footer if not repeating #35

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions include/bmx/mxf_op1a/OP1AIndexTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -243,7 +244,7 @@ class OP1AIndexTable
int64_t mStreamOffset;

std::vector<OP1AIndexTableSegment*> mWrittenVBEIndexSegments;
bool mHaveWrittenCBE;
bool mHaveWritten;
};


Expand Down
8 changes: 5 additions & 3 deletions src/mxf_op1a/OP1AFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
9 changes: 4 additions & 5 deletions src/mxf_op1a/OP1AIndexTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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);
}
Expand All @@ -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++)
Expand Down
2 changes: 1 addition & 1 deletion test/mxf_op1a/index_follows_1.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ee3d6981614538f9a2d3e4195f7d1d2f
d990fca91ecc74c9e12ee801a563c02b
2 changes: 1 addition & 1 deletion test/mxf_op1a/index_follows_2.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d2bd65039ccd59595eb8da9b6324c038
3f26e93f899bfe454f41226d0d4faf3a
2 changes: 1 addition & 1 deletion test/mxf_op1a/index_follows_3.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ee3d6981614538f9a2d3e4195f7d1d2f
73eea14e07de444a6f9be8a60c7a25d0
2 changes: 1 addition & 1 deletion test/mxf_op1a/index_follows_4.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5536a39e8a0b4ad9df369192ecc763fb
868f576736fad1be3d9d19f07775a858
2 changes: 1 addition & 1 deletion test/mxf_op1a/index_follows_5.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5536a39e8a0b4ad9df369192ecc763fb
73eea14e07de444a6f9be8a60c7a25d0
1 change: 1 addition & 0 deletions test/mxf_op1a/index_follows_6.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aa160bdf9c305623a921373bf9afc06a
1 change: 1 addition & 0 deletions test/mxf_op1a/index_follows_7.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
13d9d50ce342c5cb9685436ca2a10c1a
16 changes: 12 additions & 4 deletions test/mxf_op1a/test_indexfollows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand All @@ -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
)

Expand All @@ -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)
Expand Down Expand Up @@ -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
)

Expand Down