Skip to content

Commit

Permalink
apps: add --last-index-in-footer option
Browse files Browse the repository at this point in the history
Supports RDD 44 files that aren't segmented, where all index tables
shall be stored into the footer, header or both. Using the option will
ensure that the last index table segment is stored in the footer.

This option can be used with --repeat-index to avoid writing the last
index table segment twice, especially if there is only 1 segment.
  • Loading branch information
philipnbbc committed Aug 16, 2023
1 parent e3bf355 commit 421cf6f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apps/bmxtranswrap/bmxtranswrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,9 @@ static void usage(const char *cmd)
printf(" --body-part Create separate body partitions for essence data\n");
printf(" and don't create separate body partitions for index table segments\n");
printf(" --repeat-index Repeat the index table segments in the footer partition\n");
printf(" --last-index-in-footer Write the last index table segment in the footer partition rather than in a body partition\n");
printf(" Use in combination with --repeat-index to avoid writing the last index table segment twice,\n");
printf(" especially if there is only 1 index table segment\n");
printf(" --clip-wrap Use clip wrapping for a single sound track\n");
printf(" --mp-track-num Use the material package track number property to define a track order. By default the track number is set to 0\n");
printf(" --aes-3 Use AES-3 audio mapping\n");
Expand Down Expand Up @@ -889,6 +892,7 @@ int main(int argc, const char** argv)
bool min_part = false;
bool body_part = false;
bool repeat_index = false;
bool last_index_in_footer = false;
bool cbe_index_duration_0 = false;
bool op1a_clip_wrap = false;
bool realtime = false;
Expand Down Expand Up @@ -2340,6 +2344,10 @@ int main(int argc, const char** argv)
{
repeat_index = true;
}
else if (strcmp(argv[cmdln_index], "--last-index-in-footer") == 0)
{
last_index_in_footer = true;
}
else if (strcmp(argv[cmdln_index], "--cbe-index-duration-0") == 0)
{
cbe_index_duration_0 = true;
Expand Down Expand Up @@ -3680,6 +3688,8 @@ int main(int argc, const char** argv)
op1a_clip->SetRepeatIndexTable(true);
if (op1a_index_follows)
op1a_clip->SetIndexFollowsEssence(true);
if (last_index_in_footer)
op1a_clip->SetLastIndexInFooter(true);

if (st379_2)
op1a_clip->SetSignalST3792(true);
Expand Down
10 changes: 10 additions & 0 deletions apps/raw2bmx/raw2bmx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,9 @@ static void usage(const char *cmd)
printf(" --body-part Create separate body partitions for essence data\n");
printf(" and don't create separate body partitions for index table segments\n");
printf(" --repeat-index Repeat the index table segments in the footer partition\n");
printf(" --last-index-in-footer Write the last index table segment in the footer partition rather than in a body partition\n");
printf(" Use in combination with --repeat-index to avoid writing the last index table segment twice,\n");
printf(" especially if there is only 1 index table segment\n");
printf(" --clip-wrap Use clip wrapping for a single sound track\n");
printf(" --mp-track-num Use the material package track number property to define a track order. By default the track number is set to 0\n");
printf(" --aes-3 Use AES-3 audio mapping\n");
Expand Down Expand Up @@ -926,6 +929,7 @@ int main(int argc, const char** argv)
bool min_part = false;
bool body_part = false;
bool repeat_index = false;
bool last_index_in_footer = false;
bool op1a_clip_wrap = false;
bool allow_no_avci_head = false;
bool force_no_avci_head = false;
Expand Down Expand Up @@ -1466,6 +1470,10 @@ int main(int argc, const char** argv)
{
repeat_index = true;
}
else if (strcmp(argv[cmdln_index], "--last-index-in-footer") == 0)
{
last_index_in_footer = true;
}
else if (strcmp(argv[cmdln_index], "--mp-track-num") == 0)
{
mp_track_num = true;
Expand Down Expand Up @@ -4978,6 +4986,8 @@ int main(int argc, const char** argv)
op1a_clip->SetRepeatIndexTable(true);
if (op1a_index_follows)
op1a_clip->SetIndexFollowsEssence(true);
if (last_index_in_footer)
op1a_clip->SetLastIndexInFooter(true);

if (st379_2)
op1a_clip->SetSignalST3792(true);
Expand Down
2 changes: 2 additions & 0 deletions include/bmx/mxf_op1a/OP1AFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class OP1AFile
void SetPrimaryPackage(bool enable); // default false
void SetIndexFollowsEssence(bool enable); // default false. If true then place index partition after the essence it indexes, even for CBE
void SetSignalST3792(bool enable); // default false. If true then signal ST 379-2 compliance using sub-descriptor
void SetLastIndexInFooter(bool enable); // default false. If true then write the last index table in the footer partition rather than a body partition

public:
void SetOutputStartOffset(int64_t offset);
Expand Down Expand Up @@ -189,6 +190,7 @@ class OP1AFile
mxfUL mOPLabel;
bool mIndexFollowsEssence;
bool mSignalST3792;
bool mLastIndexInFooter;

int64_t mOutputStartOffset;
int64_t mOutputEndOffset;
Expand Down
7 changes: 7 additions & 0 deletions src/mxf_op1a/OP1AFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ OP1AFile::OP1AFile(int flavour, mxfpp::File *mxf_file, mxfRational frame_rate)
mSetPrimaryPackage = false;
mIndexFollowsEssence = false;
mSignalST3792 = false;
mLastIndexInFooter = false;

mTrackIdHelper.SetId("TimecodeTrack", 901);
mTrackIdHelper.SetStartId(MXF_PICTURE_DDEF, 1001);
Expand Down Expand Up @@ -290,6 +291,11 @@ void OP1AFile::SetSignalST3792(bool enable)
mSignalST3792 = enable;
}

void OP1AFile::SetLastIndexInFooter(bool enable)
{
mLastIndexInFooter = enable;
}

void OP1AFile::SetOutputStartOffset(int64_t offset)
{
BMX_CHECK(offset >= 0);
Expand Down Expand Up @@ -529,6 +535,7 @@ void OP1AFile::CompleteWrite()
if (HAVE_PRIMARY_EC &&
!(mFlavour & OP1A_MIN_PARTITIONS_FLAVOUR) &&
!(mFlavour & OP1A_BODY_PARTITIONS_FLAVOUR) &&
!mLastIndexInFooter &&
((mIndexTable->IsVBE() && mIndexTable->HaveSegments()) ||
(mIndexTable->IsCBE() && !mIndexTable->HaveWrittenCBE() && mIndexTable->GetDuration() > 0)))
{
Expand Down

0 comments on commit 421cf6f

Please sign in to comment.