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

JPEG XS essence support #48

Merged
merged 5 commits into from
Jan 15, 2024
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
7 changes: 7 additions & 0 deletions apps/bmxtranswrap/bmxtranswrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4202,6 +4202,13 @@ int main(int argc, const char** argv)
if (BMX_OPT_PROP_IS_SET(user_aspect_ratio))
clip_track->SetAspectRatio(user_aspect_ratio);
break;
case JPEGXS_CDCI:
case JPEGXS_RGBA:
if (afd)
clip_track->SetAFD(afd);
if (BMX_OPT_PROP_IS_SET(user_aspect_ratio))
clip_track->SetAspectRatio(user_aspect_ratio);
break;
philipnbbc marked this conversation as resolved.
Show resolved Hide resolved
case VC2:
if (afd)
clip_track->SetAFD(afd);
Expand Down
78 changes: 67 additions & 11 deletions apps/raw2bmx/raw2bmx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include <bmx/essence_parser/J2CEssenceParser.h>
#include <bmx/essence_parser/VC3EssenceParser.h>
#include <bmx/essence_parser/VC2EssenceParser.h>
#include <bmx/essence_parser/JXSEssenceParser.h>
#include <bmx/essence_parser/RawEssenceReader.h>
#include <bmx/essence_parser/FileEssenceSource.h>
#include <bmx/essence_parser/KLVEssenceSource.h>
Expand Down Expand Up @@ -105,6 +106,7 @@ typedef enum
D10_ESSENCE_GROUP,
AVCI_ESSENCE_GROUP,
AVC_ESSENCE_GROUP,
JXS_ESSENCE_GROUP,
} EssenceTypeGroup;


Expand Down Expand Up @@ -802,12 +804,18 @@ static void usage(const char *cmd)
printf(" --rdd36_422_hq <name> Raw SMPTE RDD-36 (ProRes) 4:2:2 HQ profile input file\n");
printf(" --rdd36_4444 <name> Raw SMPTE RDD-36 (ProRes) 4:4:4:4 profile input file\n");
printf(" --rdd36_4444_xq <name> Raw SMPTE RDD-36 (ProRes) 4:4:4:4 XQ profile input file\n");
printf(" --j2c_cdci <name|j2cpattern> Raw JPEG 2000 (ISO/IEC 15444-1) codestream representing components (e.g. YCbCr) described by a MXF CDCI descriptor\n");
printf(" If a '%%' is in the value then it is assumed to be a <j2cpattern> for a sequence of files, each containing a single frame\n");
printf(" See Notes below for a detailed description of <j2cpattern>\n");
printf(" --j2c_rgba <name|j2cpattern> Raw JPEG 2000 (ISO/IEC 15444-1) codestream representing components (e.g. RGB) described by a MXF RGBA descriptor\n");
printf(" If a '%%' is in the value then it is assumed to be a <j2cpattern> for a sequence of files, each containing a single frame\n");
printf(" See Notes below for a detailed description of <j2cpattern>\n");
printf(" --j2c_cdci <name|file pattern> Raw JPEG 2000 (ISO/IEC 15444-1) codestream representing components (e.g. YCbCr) described by a MXF CDCI descriptor\n");
printf(" If a '%%' is in the value then it is assumed to be a <file pattern> for a sequence of files, each containing a single frame\n");
printf(" See Notes below for a detailed description of <file pattern>\n");
printf(" --j2c_rgba <name|file pattern> Raw JPEG 2000 (ISO/IEC 15444-1) codestream representing components (e.g. RGB) described by a MXF RGBA descriptor\n");
printf(" If a '%%' is in the value then it is assumed to be a <file pattern> for a sequence of files, each containing a single frame\n");
printf(" See Notes below for a detailed description of <file pattern>\n");
printf(" --jxs_cdci <name|file pattern> Raw JPEG XS codestream representing components (e.g. YCbCr) described by a MXF CDCI descriptor\n");
printf(" If a '%%' is in the value then it is assumed to be a <file pattern> for a sequence of files, each containing a single frame\n");
printf(" See Notes below for a detailed description of <file pattern>\n");
printf(" --jxs_rgba <name|file pattern> Raw JPEG XS codestream representing components (e.g. RGB) described by a MXF RGBA descriptor\n");
printf(" If a '%%' is in the value then it is assumed to be a <file pattern> for a sequence of files, each containing a single frame\n");
printf(" See Notes below for a detailed description of <file pattern>\n");
printf(" --vc2 <name> Raw VC2 input file\n");
printf(" --vc3 <name> Raw VC3/DNxHD input file\n");
printf(" --vc3_1080p_1235 <name> Raw VC3/DNxHD 1920x1080p 220/185/175 Mbps 10bit input file\n");
Expand Down Expand Up @@ -845,9 +853,9 @@ static void usage(const char *cmd)
printf(" - <umid> format is 64 hexadecimal characters and any '.' and '-' characters are ignored\n");
printf(" - <uuid> format is 32 hexadecimal characters and any '.' and '-' characters are ignored\n");
printf(" - <tstamp> format is YYYY-MM-DDThh:mm:ss:qm where qm is in units of 1/250th second\n");
printf(" - <j2cpattern>: Each file name must include an integer frame number in the sequence.\n");
printf(" <j2cpattern> is a file path that must contain a single '%%d' where the frame number appears in the name.\n");
printf(" <j2cpattern> must not contain any other '%%' characters.\n");
printf(" - <file pattern>: Each file name must include an integer frame number in the sequence.\n");
printf(" <file pattern> is a file path that must contain a single '%%d' where the frame number appears in the name.\n");
printf(" <file pattern> must not contain any other '%%' characters.\n");
printf(" If --fill-pattern-gaps option is used then gaps in frame numbers are filled by repeating the previous frame.\n");
printf(" Example: 'inputs/frame_%%d.j2c' for input files `inputs/frame_00001.j2c' etc..\n");
printf("\n");
Expand Down Expand Up @@ -3641,6 +3649,38 @@ int main(int argc, const char** argv)
inputs.push_back(input);
cmdln_index++;
}
else if (strcmp(argv[cmdln_index], "--jxs_rgba") == 0)
{
if (cmdln_index + 1 >= argc)
{
usage(argv[0]);
fprintf(stderr, "Missing argument for input '%s'\n", argv[cmdln_index]);
return 1;
}
input.essence_type = JPEGXS_RGBA;
if (strchr(argv[cmdln_index + 1], '%') != 0)
input.file_pattern = argv[cmdln_index + 1];
else
input.filename = argv[cmdln_index + 1];
inputs.push_back(input);
cmdln_index++;
}
else if (strcmp(argv[cmdln_index], "--jxs_cdci") == 0)
{
if (cmdln_index + 1 >= argc)
{
usage(argv[0]);
fprintf(stderr, "Missing argument for input '%s'\n", argv[cmdln_index]);
return 1;
}
input.essence_type = JPEGXS_CDCI;
if (strchr(argv[cmdln_index + 1], '%') != 0)
input.file_pattern = argv[cmdln_index + 1];
else
input.filename = argv[cmdln_index + 1];
inputs.push_back(input);
cmdln_index++;
}
else if (strcmp(argv[cmdln_index], "--rdd36_422_proxy") == 0)
{
if (cmdln_index + 1 >= argc)
Expand Down Expand Up @@ -3745,9 +3785,9 @@ int main(int argc, const char** argv)
}
input.essence_type = JPEG2000_RGBA;
if (strchr(argv[cmdln_index + 1], '%') != 0)
input.file_pattern = argv[cmdln_index + 1];
input.file_pattern = argv[cmdln_index + 1];
else
input.filename = argv[cmdln_index + 1];
input.filename = argv[cmdln_index + 1];
inputs.push_back(input);
cmdln_index++;
}
Expand Down Expand Up @@ -5500,6 +5540,12 @@ int main(int argc, const char** argv)
if (BMX_OPT_PROP_IS_SET(input->afd))
clip_track->SetAFD(input->afd);
break;
case JPEGXS_CDCI:
case JPEGXS_RGBA:
clip_track->SetAspectRatio(input->aspect_ratio);
if (BMX_OPT_PROP_IS_SET(input->afd))
clip_track->SetAFD(input->afd);
break;
case VC2:
clip_track->SetAspectRatio(input->aspect_ratio);
if (BMX_OPT_PROP_IS_SET(input->afd))
Expand Down Expand Up @@ -5752,6 +5798,16 @@ int main(int argc, const char** argv)
input->raw_reader->SetEssenceParser(new J2CEssenceParser());
input->raw_reader->SetCheckMaxSampleSize(100000000);
break;
case JPEGXS_CDCI:
case JPEGXS_RGBA:
input->sample_sequence[0] = 1;
input->sample_sequence_size = 1;
input->raw_reader->SetEssenceParser(new JXSEssenceParser());
input->raw_reader->SetCheckMaxSampleSize(100000000);
input->raw_reader->SetMaxReadLength(30000000);
input->raw_reader->SetFrameStartSize(30000000); // 4k, 3bpp, RGB
input->raw_reader->SetReadBlockSize(30000000);
break;
case VC2:
input->sample_sequence[0] = 1;
input->sample_sequence_size = 1;
Expand Down
68 changes: 68 additions & 0 deletions deps/libMXF/mxf/mxf_baseline_data_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -2064,6 +2064,74 @@ MXF_SET_DEFINITION(SubDescriptor, ContainerConstraintsSubDescriptor,
MXF_LABEL(0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x67,0x00)
);

MXF_SET_DEFINITION(SubDescriptor, JPEGXSSubDescriptor,
MXF_LABEL(0x06, 0x0e, 0x2b, 0x34, 0x02, 0x53, 0x01, 0x01, 0x0d, 0x01, 0x01, 0x01, 0x01, 0x01, 0x81, 0x02)
);

MXF_ITEM_DEFINITION(JPEGXSSubDescriptor, JPEGXSPpih,
MXF_LABEL(0x06, 0x0e, 0x2b, 0x34, 0x01, 0x01, 0x01, 0x0e, 0x04, 0x01, 0x06, 0x0b, 0x01, 0x00, 0x00, 0x00),
0x0000,
MXF_UINT16_TYPE,
1
);

MXF_ITEM_DEFINITION(JPEGXSSubDescriptor, JPEGXSPlev,
MXF_LABEL(0x06, 0x0e, 0x2b, 0x34, 0x01, 0x01, 0x01, 0x0e, 0x04, 0x01, 0x06, 0x0b, 0x02, 0x00, 0x00, 0x00),
0x0000,
MXF_UINT16_TYPE,
1
);

MXF_ITEM_DEFINITION(JPEGXSSubDescriptor, JPEGXSWf,
MXF_LABEL(0x06, 0x0e, 0x2b, 0x34, 0x01, 0x01, 0x01, 0x0e, 0x04, 0x01, 0x06, 0x0b, 0x03, 0x00, 0x00, 0x00),
0x0000,
MXF_UINT16_TYPE,
1
);

MXF_ITEM_DEFINITION(JPEGXSSubDescriptor, JPEGXSHf,
MXF_LABEL(0x06, 0x0e, 0x2b, 0x34, 0x01, 0x01, 0x01, 0x0e, 0x04, 0x01, 0x06, 0x0b, 0x04, 0x00, 0x00, 0x00),
0x0000,
MXF_UINT16_TYPE,
1
);

MXF_ITEM_DEFINITION(JPEGXSSubDescriptor, JPEGXSNc,
MXF_LABEL(0x06, 0x0e, 0x2b, 0x34, 0x01, 0x01, 0x01, 0x0e, 0x04, 0x01, 0x06, 0x0b, 0x05, 0x00, 0x00, 0x00),
0x0000,
MXF_UINT8_TYPE,
1
);

MXF_ITEM_DEFINITION(JPEGXSSubDescriptor, JPEGXSComponentTable,
MXF_LABEL(0x06, 0x0e, 0x2b, 0x34, 0x01, 0x01, 0x01, 0x0e, 0x04, 0x01, 0x06, 0x0b, 0x06, 0x00, 0x00, 0x00),
0x0000,
MXF_UINT8ARRAY_TYPE,
1
);

MXF_ITEM_DEFINITION(JPEGXSSubDescriptor, JPEGXSCw,
MXF_LABEL(0x06, 0x0e, 0x2b, 0x34, 0x01, 0x01, 0x01, 0x0e, 0x04, 0x01, 0x06, 0x0b, 0x07, 0x00, 0x00, 0x00),
0x0000,
MXF_UINT16_TYPE,
0
);

MXF_ITEM_DEFINITION(JPEGXSSubDescriptor, JPEGXSHsl,
MXF_LABEL(0x06, 0x0e, 0x2b, 0x34, 0x01, 0x01, 0x01, 0x0e, 0x04, 0x01, 0x06, 0x0b, 0x08, 0x00, 0x00, 0x00),
0x0000,
MXF_UINT16_TYPE,
0
);

MXF_ITEM_DEFINITION(JPEGXSSubDescriptor, JPEGXSMaximumBitRate,
MXF_LABEL(0x06, 0x0e, 0x2b, 0x34, 0x01, 0x01, 0x01, 0x0e, 0x04, 0x01, 0x06, 0x0b, 0x09, 0x00, 0x00, 0x00),
0x0000,
MXF_UINT32_TYPE,
0
);


MXF_SET_DEFINITION(SubDescriptor, RIFFChunkDefinitionSubDescriptor,
MXF_LABEL(0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x81,0x0d)
);
Expand Down
6 changes: 6 additions & 0 deletions deps/libMXF/mxf/mxf_labels_and_keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ int mxf_is_jpeg2000_ec(const mxfUL *label)
label->octet13 == 0x0c;
}

int mxf_is_jpegxs_ec(const mxfUL *label)
{
return mxf_is_generic_container_label(label) &&
label->octet13 == 0x21;
}


void mxf_complete_essence_element_key(mxfKey *key, uint8_t count, uint8_t type, uint8_t num)
{
Expand Down
40 changes: 40 additions & 0 deletions deps/libMXF/mxf/mxf_labels_and_keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,22 @@ static const mxfUL MXF_CMDEF_L(JPEG2000_HTJ2K_GENERIC) = MXF_JPEG2000_CMDEV_L(MX
void mxf_get_jpeg2000_coding_label(uint16_t profile, uint8_t main_level, uint8_t sub_level, mxfUL *label);


/* JPEG XS */

#define MXF_JPEGXS_CMDEV_L(profile) \
{0x06, 0x0e, 0x2b, 0x34, 0x04, 0x01, 0x01, 0x0d, 0x04, 0x01, 0x02, 0x02, 0x03, 0x08, profile, 0x00}

static const mxfUL MXF_CMDEF_L(JPEGXSPictureCodingSchemes) = MXF_JPEGXS_CMDEV_L(0x00);
static const mxfUL MXF_CMDEF_L(JPEGXSUnrestrictedCodestream) = MXF_JPEGXS_CMDEV_L(0x01);
static const mxfUL MXF_CMDEF_L(JPEGXSMain422_10Profile) = MXF_JPEGXS_CMDEV_L(0x02);
static const mxfUL MXF_CMDEF_L(JPEGXSMain444_12Profile) = MXF_JPEGXS_CMDEV_L(0x03);
static const mxfUL MXF_CMDEF_L(JPEGXSMain4444_12Profile) = MXF_JPEGXS_CMDEV_L(0x04);
static const mxfUL MXF_CMDEF_L(JPEGXSLight422_10Profile) = MXF_JPEGXS_CMDEV_L(0x05);
static const mxfUL MXF_CMDEF_L(JPEGXSLight444_12Profile) = MXF_JPEGXS_CMDEV_L(0x06);
static const mxfUL MXF_CMDEF_L(JPEGXSLightSubline422_10Profile) = MXF_JPEGXS_CMDEV_L(0x07);
static const mxfUL MXF_CMDEF_L(JPEGXSHigh444_12Profile) = MXF_JPEGXS_CMDEV_L(0x08);
static const mxfUL MXF_CMDEF_L(JPEGXSHigh4444_12Profile) = MXF_JPEGXS_CMDEV_L(0x09);

/* uncompressed picture coding */

/* fourcc 2vuy */
Expand Down Expand Up @@ -572,6 +588,18 @@ static const mxfUL MXF_EC_L(JPEG2000P1Wrapped) = MXF_JPEG2000_EC_L(0x0d, 0x06);

int mxf_is_jpeg2000_ec(const mxfUL *label);

/* JPEG XS */

#define MXF_JPEGXS_EC_L(byte15) \
MXF_GENERIC_CONTAINER_LABEL(0x0d, 0x21, byte15, 0x00)

static const mxfUL MXF_EC_L(MXFGCJPEGXSPictures) = MXF_JPEGXS_EC_L(0x00);
static const mxfUL MXF_EC_L(MXFGCFrameWrappedProgressiveJPEGXSPictures) = MXF_JPEGXS_EC_L(0x01);
static const mxfUL MXF_EC_L(MXFGCFrameWrappedInterlacedJPEGXSPictures) = MXF_JPEGXS_EC_L(0x02);
static const mxfUL MXF_EC_L(MXFGCClipWrappedJPEGXSPictures) = MXF_JPEGXS_EC_L(0x03);

int mxf_is_jpegxs_ec(const mxfUL *label);


/* Data */

Expand Down Expand Up @@ -907,6 +935,18 @@ static const mxfKey MXF_EE_K(SDTI_CP_System_Pack) =
#define MXF_JPEG2000_CLIP_WRAPPED_EE_TYPE 0x09


/* JPEG XS */

#define MXF_JPEGXS_EE_K(elecount, eletype, elenum) \
MXF_GENERIC_CONTAINER_ELEMENT_KEY(0x01, 0x15, elecount, eletype, elenum)

#define MXF_JPEGXS_TRACK_NUM(elecount, eletype, elenum) \
MXF_TRACK_NUM(0x15, elecount, eletype, elenum)

#define MXF_JPEGXS_FRAME_WRAPPED_EE_TYPE 0x1A
#define MXF_JPEGXS_CLIP_WRAPPED_EE_TYPE 0x1B


/* Data mappings */

static const mxfUL MXF_EE_K(VBIData) = MXF_GENERIC_CONTAINER_ELEMENT_KEY(0x01, 0x17, 0x01, 0x01, 0x01);
Expand Down
1 change: 1 addition & 0 deletions deps/libMXFpp/libMXF++/HeaderMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ void HeaderMetadata::initialiseObjectFactory()
REGISTER_CLASS(DCTimedTextDescriptor);
REGISTER_CLASS(DCTimedTextResourceSubDescriptor);
REGISTER_CLASS(JPEG2000SubDescriptor);
REGISTER_CLASS(JPEGXSSubDescriptor);
REGISTER_CLASS(RIFFChunkDefinitionSubDescriptor);
REGISTER_CLASS(ADM_CHNASubDescriptor);
REGISTER_CLASS(ADMAudioMetadataSubDescriptor);
Expand Down
2 changes: 2 additions & 0 deletions deps/libMXFpp/libMXF++/metadata/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ list(APPEND MXFpp_sources
metadata/Identification.cpp
metadata/InterchangeObject.cpp
metadata/JPEG2000SubDescriptor.cpp
metadata/JPEGXSSubDescriptor.cpp
metadata/Locator.cpp
metadata/MCALabelSubDescriptor.cpp
metadata/MGAAudioMetadataSubDescriptor.cpp
Expand Down Expand Up @@ -95,6 +96,7 @@ list(APPEND MXFpp_headers
metadata/Identification.h
metadata/InterchangeObject.h
metadata/JPEG2000SubDescriptor.h
metadata/JPEGXSSubDescriptor.h
metadata/Locator.h
metadata/MCALabelSubDescriptor.h
metadata/MGAAudioMetadataSubDescriptor.h
Expand Down
52 changes: 52 additions & 0 deletions deps/libMXFpp/libMXF++/metadata/JPEGXSSubDescriptor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (C) 2023, Fraunhofer IIS
* All Rights Reserved.
*
* Author: Nisha Bhaskar
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the British Broadcasting Corporation nor the names
* of its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <libMXF++/MXF.h>

using namespace std;
using namespace mxfpp;



JPEGXSSubDescriptor::JPEGXSSubDescriptor(HeaderMetadata *headerMetadata)
: JPEGXSSubDescriptorBase(headerMetadata)
{}

JPEGXSSubDescriptor::JPEGXSSubDescriptor(HeaderMetadata *headerMetadata, ::MXFMetadataSet *cMetadataSet)
: JPEGXSSubDescriptorBase(headerMetadata, cMetadataSet)
{}

JPEGXSSubDescriptor::~JPEGXSSubDescriptor()
{}
Loading