Skip to content

Commit

Permalink
Merge pull request #25 from bbc/philipn-rdd44-compliance
Browse files Browse the repository at this point in the history
Changes to improve RDD 44 compliance
  • Loading branch information
philipnbbc authored Aug 22, 2023
2 parents 86b3c86 + 3767d20 commit d448677
Show file tree
Hide file tree
Showing 30 changed files with 230 additions and 148 deletions.
30 changes: 30 additions & 0 deletions apps/bmxtranswrap/bmxtranswrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ static void usage(const char *cmd)
printf(" --frame-layout <value> Override or set the video frame layout. The <value> is one of the following:\n");
printf(" 'fullframe', 'separatefield', 'singlefield', 'mixedfield', 'segmentedframe'\n");
printf(" --field-dom <value> Override or set which field is first in temporal order. The <value> is 1 or 2\n");
printf(" --video-line-map <value> Override or set the video line map. The <value> is 2 line numbers separated by a comma\n");
printf(" --transfer-ch <value> Override or set the transfer characteristic label\n");
printf(" The <value> is a SMPTE UL, formatted as a 'urn:smpte:ul:...' or one of the following:\n");
printf(" 'bt470', 'bt709', 'st240', 'st274', 'bt1361', 'linear', 'dcdm',\n");
Expand Down Expand Up @@ -619,6 +620,8 @@ static void usage(const char *cmd)
printf(" --system-item Add system item\n");
printf(" --primary-package Set the header metadata set primary package property to the top-level file source package\n");
printf(" --index-follows The index partition follows the essence partition, even when it is CBE essence\n");
printf(" --st379-2 Add ContainerConstraintsSubDescriptor to signal compliance with ST 379-2, MXF Constrained Generic Container\n");
printf(" The sub-descriptor will be added anyway if there is RDD 36 video present\n");
printf("\n");
printf(" op1a/rdd9:\n");
printf(" --ard-zdf-hdf Use the ARD ZDF HDF profile\n");
Expand Down Expand Up @@ -777,6 +780,7 @@ int main(int argc, const char** argv)
bool op1a_system_item = false;
bool op1a_primary_package = false;
bool op1a_index_follows = false;
bool st379_2 = false;
AS10Shim as10_shim = AS10_UNKNOWN_SHIM;
const char *output_name = "";
map<EssenceType, string> filename_essence_type_names;
Expand Down Expand Up @@ -830,6 +834,7 @@ int main(int argc, const char** argv)
BMX_OPT_PROP_DECL_DEF(MXFSignalStandard, user_signal_standard, MXF_SIGNAL_STANDARD_NONE);
BMX_OPT_PROP_DECL_DEF(MXFFrameLayout, user_frame_layout, MXF_FULL_FRAME);
BMX_OPT_PROP_DECL_DEF(uint8_t, user_field_dominance, 1);
BMX_OPT_PROP_DECL_DEF(mxfVideoLineMap, user_video_line_map, g_Null_Video_Line_Map);
BMX_OPT_PROP_DECL_DEF(mxfUL, user_transfer_ch, g_Null_UL);
BMX_OPT_PROP_DECL_DEF(mxfUL, user_coding_equations, g_Null_UL);
BMX_OPT_PROP_DECL_DEF(mxfUL, user_color_primaries, g_Null_UL);
Expand Down Expand Up @@ -1541,6 +1546,22 @@ int main(int argc, const char** argv)
BMX_OPT_PROP_MARK(user_field_dominance, true);
cmdln_index++;
}
else if (strcmp(argv[cmdln_index], "--video-line-map") == 0)
{
if (cmdln_index + 1 >= argc)
{
usage_ref(argv[0]);
fprintf(stderr, "Missing argument for Option '%s'\n", argv[cmdln_index]);
return 1;
}
if (!parse_video_line_map(argv[cmdln_index + 1], &user_video_line_map)) {
usage_ref(argv[0]);
fprintf(stderr, "Invalid value '%s' for Option '%s'\n", argv[cmdln_index + 1], argv[cmdln_index]);
return 1;
}
BMX_OPT_PROP_MARK(user_video_line_map, true);
cmdln_index++;
}
else if (strcmp(argv[cmdln_index], "--transfer-ch") == 0)
{
if (cmdln_index + 1 >= argc)
Expand Down Expand Up @@ -2351,6 +2372,10 @@ int main(int argc, const char** argv)
{
op1a_index_follows = true;
}
else if (strcmp(argv[cmdln_index], "--st379-2") == 0)
{
st379_2 = true;
}
else if (strcmp(argv[cmdln_index], "--ard-zdf-hdf") == 0)
{
ard_zdf_hdf_profile = true;
Expand Down Expand Up @@ -3656,6 +3681,9 @@ int main(int argc, const char** argv)
if (op1a_index_follows)
op1a_clip->SetIndexFollowsEssence(true);

if (st379_2)
op1a_clip->SetSignalST3792(true);

if (mp_uid_set)
op1a_clip->SetMaterialPackageUID(mp_uid);
if (fp_uid_set)
Expand Down Expand Up @@ -4254,6 +4282,8 @@ int main(int argc, const char** argv)
pict_helper->SetFrameLayout(user_frame_layout);
if (BMX_OPT_PROP_IS_SET(user_field_dominance))
pict_helper->SetFieldDominance(user_field_dominance);
if (BMX_OPT_PROP_IS_SET(user_video_line_map))
pict_helper->SetVideoLineMap(user_video_line_map);
if (BMX_OPT_PROP_IS_SET(user_transfer_ch))
pict_helper->SetTransferCharacteristic(user_transfer_ch);
if (BMX_OPT_PROP_IS_SET(user_coding_equations))
Expand Down
32 changes: 32 additions & 0 deletions apps/raw2bmx/raw2bmx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ struct RawInput
BMX_OPT_PROP_DECL(MXFSignalStandard, signal_standard);
BMX_OPT_PROP_DECL(MXFFrameLayout, frame_layout);
BMX_OPT_PROP_DECL(uint8_t, field_dominance);
BMX_OPT_PROP_DECL(mxfVideoLineMap, video_line_map);
BMX_OPT_PROP_DECL(mxfUL, transfer_ch);
BMX_OPT_PROP_DECL(mxfUL, coding_equations);
BMX_OPT_PROP_DECL(mxfUL, color_primaries);
Expand Down Expand Up @@ -340,6 +341,7 @@ static void init_input(RawInput *input)
BMX_OPT_PROP_DEFAULT(input->signal_standard, MXF_SIGNAL_STANDARD_NONE);
BMX_OPT_PROP_DEFAULT(input->frame_layout, MXF_FULL_FRAME);
BMX_OPT_PROP_DEFAULT(input->field_dominance, 1);
BMX_OPT_PROP_DEFAULT(input->video_line_map, g_Null_Video_Line_Map);
BMX_OPT_PROP_DEFAULT(input->transfer_ch, g_Null_UL);
BMX_OPT_PROP_DEFAULT(input->coding_equations, g_Null_UL);
BMX_OPT_PROP_DEFAULT(input->color_primaries, g_Null_UL);
Expand Down Expand Up @@ -526,6 +528,8 @@ static void usage(const char *cmd)
printf(" --kag-size-512 Set KAG size to 512, instead of 1\n");
printf(" --primary-package Set the header metadata set primary package property to the top-level file source package\n");
printf(" --index-follows The index partition follows the essence partition, even when it is CBE essence\n");
printf(" --st379-2 Add ContainerConstraintsSubDescriptor to signal compliance with ST 379-2, MXF Constrained Generic Container\n");
printf(" The sub-descriptor will be added anyway if there is RDD 36 video present\n");
printf("\n");
printf(" op1a/rdd9/d10:\n");
printf(" --xml-scheme-id <id> Set the XML payload scheme identifier associated with the following --embed-xml option.\n");
Expand Down Expand Up @@ -631,6 +635,7 @@ static void usage(const char *cmd)
printf(" --frame-layout <value> Set the video frame layout. The <value> is one of the following:\n");
printf(" 'fullframe', 'separatefield', 'singlefield', 'mixedfield', 'segmentedframe'\n");
printf(" --field-dom <value> Set which field is first in temporal order. The <value> is 1 or 2\n");
printf(" --video-line-map <value> Override or set the video line map. The <value> is 2 line numbers separated by a comma\n");
printf(" --transfer-ch <value> Set the transfer characteristic label\n");
printf(" The <value> is a SMPTE UL, formatted as a 'urn:smpte:ul:...' or one of the following:\n");
printf(" 'bt470', 'bt709', 'st240', 'st274', 'bt1361', 'linear', 'dcdm',\n");
Expand Down Expand Up @@ -859,6 +864,7 @@ int main(int argc, const char** argv)
bool kag_size_512 = false;
bool op1a_primary_package = false;
bool op1a_index_follows = false;
bool st379_2 = false;
AS10Shim as10_shim = AS10_UNKNOWN_SHIM;
const char *mpeg_descr_defaults_name = 0;
bool mpeg_descr_frame_checks = true;
Expand Down Expand Up @@ -1480,6 +1486,10 @@ int main(int argc, const char** argv)
{
op1a_index_follows = true;
}
else if (strcmp(argv[cmdln_index], "--st379-2") == 0)
{
st379_2 = true;
}
else if (strcmp(argv[cmdln_index], "--xml-scheme-id") == 0)
{
if (cmdln_index + 1 >= argc)
Expand Down Expand Up @@ -2047,6 +2057,23 @@ int main(int argc, const char** argv)
cmdln_index++;
continue; // skip input reset at the end
}
else if (strcmp(argv[cmdln_index], "--video-line-map") == 0)
{
if (cmdln_index + 1 >= argc)
{
usage_ref(argv[0]);
fprintf(stderr, "Missing argument for Option '%s'\n", argv[cmdln_index]);
return 1;
}
if (!parse_video_line_map(argv[cmdln_index + 1], &input.video_line_map)) {
usage_ref(argv[0]);
fprintf(stderr, "Invalid value '%s' for Option '%s'\n", argv[cmdln_index + 1], argv[cmdln_index]);
return 1;
}
BMX_OPT_PROP_MARK(input.video_line_map, true);
cmdln_index++;
continue; // skip input reset at the end
}
else if (strcmp(argv[cmdln_index], "--transfer-ch") == 0)
{
if (cmdln_index + 1 >= argc)
Expand Down Expand Up @@ -4952,6 +4979,9 @@ int main(int argc, const char** argv)
if (op1a_index_follows)
op1a_clip->SetIndexFollowsEssence(true);

if (st379_2)
op1a_clip->SetSignalST3792(true);

if (mp_uid_set)
op1a_clip->SetMaterialPackageUID(mp_uid);
if (fp_uid_set)
Expand Down Expand Up @@ -5430,6 +5460,8 @@ int main(int argc, const char** argv)
pict_helper->SetFrameLayout(input->frame_layout);
if (BMX_OPT_PROP_IS_SET(input->field_dominance))
pict_helper->SetFieldDominance(input->field_dominance);
if (BMX_OPT_PROP_IS_SET(input->video_line_map))
pict_helper->SetVideoLineMap(input->video_line_map);
if (BMX_OPT_PROP_IS_SET(input->transfer_ch))
pict_helper->SetTransferCharacteristic(input->transfer_ch);
if (BMX_OPT_PROP_IS_SET(input->coding_equations))
Expand Down
2 changes: 1 addition & 1 deletion deps/libMXF
2 changes: 1 addition & 1 deletion deps/libMXFpp
5 changes: 3 additions & 2 deletions include/bmx/apps/AppUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,10 @@ bool parse_color_primaries(const char *str, UL *label);
bool parse_color_siting(const char *str, MXFColorSiting *value);
bool parse_vc2_mode(const char *mode_str, int *vc2_mode_flags);
bool parse_avid_umid_type(const char *str, AvidUMIDType *value);
int parse_three_color_primaries(const char *str, mxfThreeColorPrimaries *three_color_primaries);
int parse_color_primary(const char *str, mxfColorPrimary *color_primary);
bool parse_three_color_primaries(const char *str, mxfThreeColorPrimaries *three_color_primaries);
bool parse_color_primary(const char *str, mxfColorPrimary *color_primary);
bool parse_essence_type_names(const char *str, std::map<EssenceType, std::string> *essence_type_names);
bool parse_video_line_map(const char *str, mxfVideoLineMap *video_line_map);

std::string create_mxf_track_filename(const char *prefix, uint32_t track_number, MXFDataDefEnum data_def);

Expand Down
3 changes: 3 additions & 0 deletions include/bmx/mxf_helper/PictureMXFDescriptorHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class PictureMXFDescriptorHelper : public MXFDescriptorHelper
void SetSignalStandard(MXFSignalStandard signal_standard);
void SetFrameLayout(MXFFrameLayout frame_layout);
void SetFieldDominance(uint8_t field_num);
void SetVideoLineMap(int32_t first, int32_t second);
void SetVideoLineMap(mxfVideoLineMap video_line_map);
void SetTransferCharacteristic(mxfUL label);
void SetCodingEquations(mxfUL label);
void SetColorPrimaries(mxfUL label);
Expand Down Expand Up @@ -140,6 +142,7 @@ class PictureMXFDescriptorHelper : public MXFDescriptorHelper
BMX_OPT_PROP_DECL(MXFSignalStandard, mSignalStandard);
BMX_OPT_PROP_DECL(MXFFrameLayout, mFrameLayout);
BMX_OPT_PROP_DECL(uint8_t, mFieldDominance);
BMX_OPT_PROP_DECL(mxfVideoLineMap, mVideoLineMap);
BMX_OPT_PROP_DECL(mxfUL, mTransferCh);
BMX_OPT_PROP_DECL(mxfUL, mCodingEquations);
BMX_OPT_PROP_DECL(mxfUL, mColorPrimaries);
Expand Down
3 changes: 0 additions & 3 deletions include/bmx/mxf_helper/UncCDCIMXFDescriptorHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class UncCDCIMXFDescriptorHelper : public PictureMXFDescriptorHelper
void SetStoredDimensions(uint32_t width, uint32_t height);
void SetDisplayDimensions(uint32_t width, uint32_t height, int32_t x_offset, int32_t y_offset);
void SetSampledDimensions(uint32_t width, uint32_t height, int32_t x_offset, int32_t y_offset);
void SetVideoLineMap(int32_t field1, int32_t field2);
virtual void SetEssenceType(EssenceType essence_type);
virtual void SetSampleRate(mxfRational sample_rate);
virtual void SetFrameWrapped(bool frame_wrapped);
Expand Down Expand Up @@ -102,8 +101,6 @@ class UncCDCIMXFDescriptorHelper : public PictureMXFDescriptorHelper
uint32_t mSampledHeight;
int32_t mSampledXOffset;
int32_t mSampledYOffset;
int32_t mVideoLineMap[2];
bool mVideoLineMapSet;
};


Expand Down
3 changes: 0 additions & 3 deletions include/bmx/mxf_helper/UncRGBAMXFDescriptorHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class UncRGBAMXFDescriptorHelper : public PictureMXFDescriptorHelper
void SetStoredDimensions(uint32_t width, uint32_t height);
void SetDisplayDimensions(uint32_t width, uint32_t height, int32_t x_offset, int32_t y_offset);
void SetSampledDimensions(uint32_t width, uint32_t height, int32_t x_offset, int32_t y_offset);
void SetVideoLineMap(int32_t field1, int32_t field2);
virtual void SetEssenceType(EssenceType essence_type);
virtual void SetSampleRate(mxfRational sample_rate);

Expand Down Expand Up @@ -99,8 +98,6 @@ class UncRGBAMXFDescriptorHelper : public PictureMXFDescriptorHelper
uint32_t mSampledHeight;
int32_t mSampledXOffset;
int32_t mSampledYOffset;
int32_t mVideoLineMap[2];
bool mVideoLineMapSet;
};


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 @@ -101,6 +101,7 @@ class OP1AFile
void ForceWriteCBEDuration0(bool enable); // force duration=0 for CBE index table
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

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

int64_t mOutputStartOffset;
int64_t mOutputEndOffset;
Expand Down
2 changes: 2 additions & 0 deletions meta/extensions_mxflib_dict.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@
<EssenceStreamID type="UInt32" use="required" globalKey="06 0e 2b 34 01 01 01 04 01 03 04 04 00 00 00 00"/>
</DCTimedTextResourceSubDescriptor>

<ContainerConstraintsSubDescriptor base="SubDescriptor" type="localSet" key="06 0e 2b 34 02 53 01 01 0d 01 01 01 01 01 67 00"/>

<Filler base="StructuralComponent" type="localSet" key="06 0e 2b 34 02 53 01 01 0d 01 01 01 01 01 09 00"/>

</MXFDictionary>
16 changes: 14 additions & 2 deletions src/apps/AppUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ bool bmx::parse_avid_umid_type(const char *str, AvidUMIDType *value)
return false;
}

int bmx::parse_three_color_primaries(const char *str, mxfThreeColorPrimaries *three_color_primaries)
bool bmx::parse_three_color_primaries(const char *str, mxfThreeColorPrimaries *three_color_primaries)
{
unsigned int value[6];
if (sscanf(str, "%d,%d,%d,%d,%d,%d", &value[0], &value[1], &value[2], &value[3], &value[4], &value[5]) != 6)
Expand All @@ -1013,7 +1013,7 @@ int bmx::parse_three_color_primaries(const char *str, mxfThreeColorPrimaries *th
return true;
}

int bmx::parse_color_primary(const char *str, mxfColorPrimary *color_primary)
bool bmx::parse_color_primary(const char *str, mxfColorPrimary *color_primary)
{
unsigned int value[2];
if (sscanf(str, "%d,%d", &value[0], &value[1]) != 2)
Expand All @@ -1039,6 +1039,18 @@ bool bmx::parse_essence_type_names(const char *str, map<EssenceType, string> *es
return true;
}

bool bmx::parse_video_line_map(const char *str, mxfVideoLineMap *video_line_map)
{
int value[2];
if (sscanf(str, "%d,%d", &value[0], &value[1]) != 2)
return false;

video_line_map->first = value[0];
video_line_map->second = value[1];

return true;
}


string bmx::create_mxf_track_filename(const char *prefix, uint32_t track_number, MXFDataDefEnum data_def)
{
Expand Down
9 changes: 3 additions & 6 deletions src/mxf_helper/AVCIMXFDescriptorHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,7 @@ void AVCIMXFDescriptorHelper::UpdateFileDescriptor()
cdci_descriptor->setStoredHeight(544);
else
cdci_descriptor->setStoredHeight(540);
cdci_descriptor->appendVideoLineMap(21);
cdci_descriptor->appendVideoLineMap(584);
cdci_descriptor->setVideoLineMap(21, 584);
break;
case AVCI200_1080P:
case AVCI100_1080P:
Expand All @@ -393,16 +392,14 @@ void AVCIMXFDescriptorHelper::UpdateFileDescriptor()
cdci_descriptor->setStoredHeight(1088);
else
cdci_descriptor->setStoredHeight(1080);
cdci_descriptor->appendVideoLineMap(42);
cdci_descriptor->appendVideoLineMap(0);
cdci_descriptor->setVideoLineMap(42, 0);
break;
case AVCI200_720P:
case AVCI100_720P:
case AVCI50_720P:
cdci_descriptor->setStoredWidth(1280);
cdci_descriptor->setStoredHeight(720);
cdci_descriptor->appendVideoLineMap(26);
cdci_descriptor->appendVideoLineMap(0);
cdci_descriptor->setVideoLineMap(26, 0);
break;
default:
BMX_ASSERT(false);
Expand Down
5 changes: 2 additions & 3 deletions src/mxf_helper/D10MXFDescriptorHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ typedef struct
uint32_t stored_width;
uint32_t stored_height;
int32_t display_y_offset;
int32_t video_line_map[2];
mxfVideoLineMap video_line_map;
} SupportedEssence;

static const SupportedEssence SUPPORTED_ESSENCE[] =
Expand Down Expand Up @@ -239,8 +239,7 @@ void D10MXFDescriptorHelper::UpdateFileDescriptor()
cdci_descriptor->setDisplayHeight(cdci_descriptor->getStoredHeight() - SUPPORTED_ESSENCE[mEssenceIndex].display_y_offset);
cdci_descriptor->setDisplayXOffset(0);
cdci_descriptor->setDisplayYOffset(SUPPORTED_ESSENCE[mEssenceIndex].display_y_offset);
cdci_descriptor->appendVideoLineMap(SUPPORTED_ESSENCE[mEssenceIndex].video_line_map[0]);
cdci_descriptor->appendVideoLineMap(SUPPORTED_ESSENCE[mEssenceIndex].video_line_map[1]);
cdci_descriptor->setVideoLineMap(SUPPORTED_ESSENCE[mEssenceIndex].video_line_map);
cdci_descriptor->setStoredF2Offset(0);
cdci_descriptor->setSampledXOffset(0);
cdci_descriptor->setSampledYOffset(0);
Expand Down
5 changes: 2 additions & 3 deletions src/mxf_helper/DVMXFDescriptorHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ typedef struct
uint32_t stored_width;
uint32_t stored_height;
uint32_t avid_stored_width;
int32_t video_line_map[2];
mxfVideoLineMap video_line_map;
uint8_t color_siting;
uint8_t frame_layout;
uint8_t signal_standard;
Expand Down Expand Up @@ -265,8 +265,7 @@ void DVMXFDescriptorHelper::UpdateFileDescriptor()
cdci_descriptor->setColorRange(225);
cdci_descriptor->setSignalStandard(SUPPORTED_ESSENCE[mEssenceIndex].signal_standard);
SetCodingEquationsMod(SUPPORTED_ESSENCE[mEssenceIndex].coding_eq);
cdci_descriptor->appendVideoLineMap(SUPPORTED_ESSENCE[mEssenceIndex].video_line_map[0]);
cdci_descriptor->appendVideoLineMap(SUPPORTED_ESSENCE[mEssenceIndex].video_line_map[1]);
cdci_descriptor->setVideoLineMap(SUPPORTED_ESSENCE[mEssenceIndex].video_line_map);
if ((mFlavour & MXFDESC_AVID_FLAVOUR))
cdci_descriptor->setStoredWidth(SUPPORTED_ESSENCE[mEssenceIndex].avid_stored_width);
else
Expand Down
6 changes: 2 additions & 4 deletions src/mxf_helper/JPEG2000MXFDescriptorHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,9 @@ void JPEG2000MXFDescriptorHelper::UpdateFileDescriptor(J2CEssenceParser *essence
}
if (!pict_descriptor->haveVideoLineMap()) {
if (pict_descriptor->getFrameLayout() == MXF_FULL_FRAME) {
pict_descriptor->appendVideoLineMap(1);
pict_descriptor->appendVideoLineMap(0);
pict_descriptor->setVideoLineMap(1, 0);
} else {
pict_descriptor->appendVideoLineMap(1);
pict_descriptor->appendVideoLineMap(pict_descriptor->getDisplayHeight() / 2 + 1);
pict_descriptor->setVideoLineMap(1, pict_descriptor->getDisplayHeight() / 2 + 1);
}
}

Expand Down
Loading

0 comments on commit d448677

Please sign in to comment.