Skip to content

Commit

Permalink
Simplifying code. Moving away from the 'B0' convention which seems to…
Browse files Browse the repository at this point in the history
… be used for InterchangeObject inheritors. Passed in byteProvider directly.
  • Loading branch information
danielhdz13-netflix committed Sep 25, 2024
1 parent 13f8911 commit 499074d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ else if (field.getType() == CompoundDataTypes.Timestamp.class)
CompoundDataTypes.Timestamp timestamp = new CompoundDataTypes.Timestamp(byteProvider);
field.set(object, timestamp);
}
else if (field.getType() == J2KExtendedCapabilities.J2KExtendedCapabilitiesB0.class) {
J2KExtendedCapabilities.J2KExtendedCapabilitiesB0 j2KExtendedCapabilitiesB0 = new J2KExtendedCapabilities.J2KExtendedCapabilitiesB0(byteProvider.getBytes(byteArraySize));
field.set(object, j2KExtendedCapabilitiesB0);
else if (field.getType() == J2KExtendedCapabilities.class) {
J2KExtendedCapabilities j2KExtendedCapabilities = new J2KExtendedCapabilities(byteProvider);
field.set(object, j2KExtendedCapabilities);
}
else if (field.getType() == CompoundDataTypes.MXFCollections.MXFCollection.class)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,18 @@
@Immutable
public final class J2KExtendedCapabilities {

private final J2KExtendedCapabilitiesB0 capabilitiesB0;

public J2KExtendedCapabilities(J2KExtendedCapabilitiesB0 capabilitiesB0) {
this.capabilitiesB0 = capabilitiesB0;
}
@MXFProperty(size=4) protected final Integer pCap = null;
@MXFProperty(size=0, depends=true) protected final CompoundDataTypes.MXFCollections.MXFCollection<Short> cCapi = null;

/**
* Object corresponding to a parsed J2KExtendedCapabilities as defined in ISO/IEC 15444-15 Annex A.5.2
* Instantiates a new parsed J2KExtendedCapabilities object
*
* @param byteProvider the bytes corresponding to the 2 fields
* @throws IOException - any I/O related error will be exposed through an IOException
*/
@Immutable
public static final class J2KExtendedCapabilitiesB0 {
@MXFProperty(size=4) protected final Integer pCap = null;
@MXFProperty(size=0, depends=true) protected final CompoundDataTypes.MXFCollections.MXFCollection<Short> cCapi = null;

/**
* Instantiates a new parsed J2KExtendedCapabilities object
*
* @param bytes the byte array corresponding to the 2 fields
* @throws IOException - any I/O related error will be exposed through an IOException
*/

public J2KExtendedCapabilitiesB0(byte[] bytes) throws IOException
{
ByteProvider byteProvider = new ByteArrayDataProvider(bytes);
MXFPropertyPopulator.populateField(byteProvider, this, "pCap");
MXFPropertyPopulator.populateField(byteProvider, this, "cCapi");
}

public J2KExtendedCapabilities(ByteProvider byteProvider) throws IOException {
MXFPropertyPopulator.populateField(byteProvider, this, "pCap");
MXFPropertyPopulator.populateField(byteProvider, this, "cCapi");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static final class JPEG2000PictureSubDescriptorBO extends SubDescriptorBO
@MXFProperty(size=0, depends=true) private final CompoundDataTypes.MXFCollections.MXFCollection<JPEG2000PictureComponent.JPEG2000PictureComponentBO> picture_component_sizing = null;
@MXFProperty(size=0, depends=false) private final byte[] coding_style_default = null;
@MXFProperty(size=0, depends=false) private final byte[] quantisation_default = null;
@MXFProperty(size=0, depends=false) private final J2KExtendedCapabilities.J2KExtendedCapabilitiesB0 j2k_extended_capabilities = null;
@MXFProperty(size=0, depends=false) private final J2KExtendedCapabilities j2k_extended_capabilities = null;

/**
* Instantiates a new JPEG2000 picture sub descriptor ByteObject.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ public void videoHeaderPartitionTest3() throws IOException
GenericPictureEssenceDescriptor.GenericPictureEssenceDescriptorBO descriptorBO = (GenericPictureEssenceDescriptor.GenericPictureEssenceDescriptorBO) TestHelper.getValue(pictureEssenceDescriptor, "rgbaPictureEssenceDescriptorBO");
InterchangeObject.InterchangeObjectBO jpeg2000SubDescriptor = headerPartition.getSubDescriptors(descriptorBO).get(0);
JPEG2000PictureSubDescriptor.JPEG2000PictureSubDescriptorBO jpeg2000PictureSubDescriptorBO = (JPEG2000PictureSubDescriptor.JPEG2000PictureSubDescriptorBO) jpeg2000SubDescriptor;
J2KExtendedCapabilities.J2KExtendedCapabilitiesB0 j2KExtendedCapabilitiesB0 = (J2KExtendedCapabilities.J2KExtendedCapabilitiesB0) TestHelper.getValue(jpeg2000PictureSubDescriptorBO, "j2k_extended_capabilities");
Integer pCap = (Integer) TestHelper.getValue(j2KExtendedCapabilitiesB0, "pCap");
List<Short> cCap = ((CompoundDataTypes.MXFCollections.MXFCollection<Short>) TestHelper.getValue(j2KExtendedCapabilitiesB0, "cCapi")).getEntries();
J2KExtendedCapabilities j2KExtendedCapabilities = (J2KExtendedCapabilities) TestHelper.getValue(jpeg2000PictureSubDescriptorBO, "j2k_extended_capabilities");
Integer pCap = (Integer) TestHelper.getValue(j2KExtendedCapabilities, "pCap");
List<Short> cCap = ((CompoundDataTypes.MXFCollections.MXFCollection<Short>) TestHelper.getValue(j2KExtendedCapabilities, "cCapi")).getEntries();

Assert.assertEquals(pCap, 131072);
Assert.assertEquals(cCap.size(), 1);
Expand Down

0 comments on commit 499074d

Please sign in to comment.