From abad6dadaaaa211e9c5ad75efdd08dd615366e64 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Arnaud Date: Thu, 29 Nov 2018 09:11:07 +0100 Subject: [PATCH 01/11] declare new colorimetry Color.8DPP - BT2020 HLG --- src/main/java/com/netflix/imflibrary/Colorimetry.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/netflix/imflibrary/Colorimetry.java b/src/main/java/com/netflix/imflibrary/Colorimetry.java index 1be3992b..0aa22eb3 100644 --- a/src/main/java/com/netflix/imflibrary/Colorimetry.java +++ b/src/main/java/com/netflix/imflibrary/Colorimetry.java @@ -22,6 +22,7 @@ public enum Colorimetry { Color6(ColorPrimaries.P3D65, TransferCharacteristic.SMPTEST2084, CodingEquation.None), Color7(ColorPrimaries.ITU2020, TransferCharacteristic.SMPTEST2084, CodingEquation.ITU2020NCL), Color_App5_AP0(ColorPrimaries.ACES, TransferCharacteristic.Linear, CodingEquation.None), + Color8DPP(ColorPrimaries.ITU2020, TransferCharacteristic.ITU2020HLG, CodingEquation.ITU2020NCL), Unknown(ColorPrimaries.Unknown, TransferCharacteristic.Unknown, CodingEquation.Unknown); @@ -87,6 +88,7 @@ public static enum TransferCharacteristic { ITU2020(UL.fromULAsURNStringToUL("urn:smpte:ul:06.0E.2B.34.04.01.01.0E.04.01.01.01.01.09.00.00")), SMPTEST2084(UL.fromULAsURNStringToUL("urn:smpte:ul:06.0E.2B.34.04.01.01.0D.04.01.01.01.01.0A.00.00")), Linear(UL.fromULAsURNStringToUL("urn:smpte:ul:06.0e.2b.34.04.01.01.06.04.01.01.01.01.06.00.00")), + ITU2020HLG(UL.fromULAsURNStringToUL("urn:smpte:ul:06.0E.2B.34.04.01.01.0D.04.01.01.01.01.0B.00.00")), Unknown(null); private final UL transferCharacteristicUL; From 93dd7ef1363842e56a5894665bc2e5c090c374d6 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Arnaud Date: Thu, 29 Nov 2018 09:12:38 +0100 Subject: [PATCH 02/11] if no subdescriptor, get the bitdepth from the componentDepth --- .../CompositionImageEssenceDescriptorModel.java | 11 +++++++---- .../st2067_2/Application2CompositionTest.java | 6 +++--- .../st2067_2/Application2ExtendedCompositionTest.java | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/netflix/imflibrary/st2067_2/CompositionImageEssenceDescriptorModel.java b/src/main/java/com/netflix/imflibrary/st2067_2/CompositionImageEssenceDescriptorModel.java index 18f86ef4..986297b9 100644 --- a/src/main/java/com/netflix/imflibrary/st2067_2/CompositionImageEssenceDescriptorModel.java +++ b/src/main/java/com/netflix/imflibrary/st2067_2/CompositionImageEssenceDescriptorModel.java @@ -384,10 +384,13 @@ public TransferCharacteristic getTransferCharacteristic() { Integer refPixelBitDepth = null; DOMNodeObjectModel subDescriptors = imageEssencedescriptorDOMNode.getDOMNode(regXMLLibDictionary.getSymbolNameFromURN(subdescriptorsUL)); if (subDescriptors == null) { - imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, - IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, - String.format("EssenceDescriptor with ID %s is missing SubDescriptors", imageEssencedescriptorID.toString())); - + Integer componentDepth = getComponentDepth(); + if (componentDepth == 0) { + imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s is missing SubDescriptors and missing Component Depth", imageEssencedescriptorID.toString())); + } + refPixelBitDepth = componentDepth; } else { DOMNodeObjectModel jpeg2000SubdescriptorDOMNode = subDescriptors.getDOMNode(regXMLLibDictionary.getSymbolNameFromURN(jpeg2000SubDescriptorUL)); diff --git a/src/test/java/com/netflix/imflibrary/st2067_2/Application2CompositionTest.java b/src/test/java/com/netflix/imflibrary/st2067_2/Application2CompositionTest.java index db580f99..0187ed9e 100644 --- a/src/test/java/com/netflix/imflibrary/st2067_2/Application2CompositionTest.java +++ b/src/test/java/com/netflix/imflibrary/st2067_2/Application2CompositionTest.java @@ -99,7 +99,7 @@ public void app2CompositionSubDescriptorsErrorTest() throws IOException { ("TestIMP/Application2/CPL_BLACKL_202_1080p_REC709_178_ENG_fe8cf2f4-1bcd-4145-8f72-6775af4038c4_SubDescriptorError.xml"); IMFErrorLogger imfErrorLogger = new IMFErrorLoggerImpl(); ApplicationCompositionFactory.getApplicationComposition(inputFile, imfErrorLogger); - Assert.assertEquals(imfErrorLogger.getErrors().size(), 5); + Assert.assertEquals(imfErrorLogger.getErrors().size(), 0); } @Test @@ -108,7 +108,7 @@ public void app2CompositionJPEG2000SubDescriptorMissingComponentDepthErrorTest() ("TestIMP/Application2/CPL_BLACKL_202_1080p_REC709_178_ENG_fe8cf2f4-1bcd-4145-8f72-6775af4038c4_SubDescriptorError_componentDepth_missing.xml"); IMFErrorLogger imfErrorLogger = new IMFErrorLoggerImpl(); ApplicationCompositionFactory.getApplicationComposition(inputFile, imfErrorLogger); - Assert.assertEquals(imfErrorLogger.getErrors().size(), 6); + Assert.assertEquals(imfErrorLogger.getErrors().size(), 1); } @Test @@ -117,7 +117,7 @@ public void app2CompositionJPEG2000SubDescriptorComponentDepthPixelDepthMismatch ("TestIMP/Application2/CPL_BLACKL_202_1080p_REC709_178_ENG_fe8cf2f4-1bcd-4145-8f72-6775af4038c4_SubDescriptorError_componentDepth_mismatch.xml"); IMFErrorLogger imfErrorLogger = new IMFErrorLoggerImpl(); ApplicationCompositionFactory.getApplicationComposition(inputFile, imfErrorLogger); - Assert.assertEquals(imfErrorLogger.getErrors().size(), 5); + Assert.assertEquals(imfErrorLogger.getErrors().size(), 2); } @Test diff --git a/src/test/java/com/netflix/imflibrary/st2067_2/Application2ExtendedCompositionTest.java b/src/test/java/com/netflix/imflibrary/st2067_2/Application2ExtendedCompositionTest.java index 39b0c6d0..782d659f 100644 --- a/src/test/java/com/netflix/imflibrary/st2067_2/Application2ExtendedCompositionTest.java +++ b/src/test/java/com/netflix/imflibrary/st2067_2/Application2ExtendedCompositionTest.java @@ -105,7 +105,7 @@ public void app2ExtendedCompositionSubDescriptorsErrorTest() throws IOException ("TestIMP/Application2Extended/CPL_BLACKL_202_1080p_REC709_178_ENG_fe8cf2f4-1bcd-4145-8f72-6775af4038c4_SubDescriptorError.xml"); IMFErrorLogger imfErrorLogger = new IMFErrorLoggerImpl(); ApplicationCompositionFactory.getApplicationComposition(inputFile, imfErrorLogger); - Assert.assertEquals(imfErrorLogger.getErrors().size(), 4); + Assert.assertEquals(imfErrorLogger.getErrors().size(), 0); } @Test From 3f7c7c1caf375ad5c119441b43898454ac2b77f3 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Arnaud Date: Thu, 29 Nov 2018 09:14:26 +0100 Subject: [PATCH 03/11] declare Application TSP 2121 --- .../ApplicationCompositionFactory.java | 5 + .../ApplicationTsp2121Composition.java | 252 ++++++++++++++++++ 2 files changed, 257 insertions(+) create mode 100644 src/main/java/com/netflix/imflibrary/st2067_2/ApplicationTsp2121Composition.java diff --git a/src/main/java/com/netflix/imflibrary/st2067_2/ApplicationCompositionFactory.java b/src/main/java/com/netflix/imflibrary/st2067_2/ApplicationCompositionFactory.java index c4e28e16..6334329f 100755 --- a/src/main/java/com/netflix/imflibrary/st2067_2/ApplicationCompositionFactory.java +++ b/src/main/java/com/netflix/imflibrary/st2067_2/ApplicationCompositionFactory.java @@ -50,10 +50,15 @@ public class ApplicationCompositionFactory { add("http://www.smpte-ra.org/ns/2067-50/2017"); }}); + private static final Set namespacesApplicationTsp2121Composition = Collections.unmodifiableSet(new HashSet() {{ + add("http://www.digitalproductionpartnership.co.uk/schema/imf/TSP2121-1/2018"); + }}); + public enum ApplicationCompositionType { APPLICATION_2_COMPOSITION_TYPE(Application2Composition.class, namespacesApplication2Composition), APPLICATION_2E_COMPOSITION_TYPE(Application2ExtendedComposition.class, namespacesApplication2EComposition), APPLICATION_5_COMPOSITION_TYPE(Application5Composition.class, namespacesApplication5Composition), + APPLICATION_TSP_2121_COMPOSITION_TYPE(ApplicationTsp2121Composition.class, namespacesApplicationTsp2121Composition), APPLICATION_UNSUPPORTED_COMPOSITION_TYPE(ApplicationUnsupportedComposition.class, Collections.unmodifiableSet(new HashSet<>())); private Set nameSpaceSet; private Class clazz; diff --git a/src/main/java/com/netflix/imflibrary/st2067_2/ApplicationTsp2121Composition.java b/src/main/java/com/netflix/imflibrary/st2067_2/ApplicationTsp2121Composition.java new file mode 100644 index 00000000..4fa824c4 --- /dev/null +++ b/src/main/java/com/netflix/imflibrary/st2067_2/ApplicationTsp2121Composition.java @@ -0,0 +1,252 @@ +package com.netflix.imflibrary.st2067_2; + +import com.netflix.imflibrary.Colorimetry; +import com.netflix.imflibrary.IMFErrorLogger; +import com.netflix.imflibrary.st0377.header.UL; +import com.netflix.imflibrary.st2067_2.ApplicationCompositionFactory.ApplicationCompositionType; +import com.netflix.imflibrary.utils.Fraction; + +import javax.annotation.Nonnull; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +import static com.netflix.imflibrary.Colorimetry.CodingEquation; +import static com.netflix.imflibrary.Colorimetry.ColorModel; +import static com.netflix.imflibrary.Colorimetry.ColorPrimaries; +import static com.netflix.imflibrary.Colorimetry.Quantization; +import static com.netflix.imflibrary.Colorimetry.Sampling; +import static com.netflix.imflibrary.Colorimetry.TransferCharacteristic; +import static com.netflix.imflibrary.st0377.header.GenericPictureEssenceDescriptor.FrameLayoutType; + +/** + * A class that models Composition with Application TSP 2121 constraints from TSP 2121-1 specification + */ +public class ApplicationTsp2121Composition extends AbstractApplicationComposition { + public static final SetresolutionsSupported = Collections.unmodifiableSet(new HashSet() {{ + add(new Fraction(1920, 1080)); add(new Fraction(3840, 2160)); }}); + public static final SetsampleRateSupported = Collections.unmodifiableSet(new HashSet() {{ + add(new Fraction(24)); add(new Fraction(25)); add(new Fraction(30)); add(new Fraction(50)); add(new Fraction(60)); + add(new Fraction(24000, 1001)); add(new Fraction(30000, 1001)); add(new Fraction(60000, 1001)); }}); + public static final SetbitDepthsSupported = Collections.unmodifiableSet(new HashSet() {{ + add(10); add(12); }}); + private static final Set ignoreSet = Collections.unmodifiableSet(new HashSet() {{ + add("SignalStandard"); + add("ActiveFormatDescriptor"); + add("VideoLineMap"); + add("AlphaTransparency"); + add("PixelLayout"); + add("ActiveHeight"); + add("ActiveWidth"); + add("ActiveXOffset"); + add("ActiveYOffset"); + }}); + + public ApplicationTsp2121Composition(@Nonnull IMFCompositionPlaylistType imfCompositionPlaylistType) { + this(imfCompositionPlaylistType, new HashSet<>()); + } + + public ApplicationTsp2121Composition(@Nonnull IMFCompositionPlaylistType imfCompositionPlaylistType, Set homogeneitySelectionSet) { + + super(imfCompositionPlaylistType, ignoreSet, homogeneitySelectionSet); + + try + { + CompositionImageEssenceDescriptorModel imageEssenceDescriptorModel = getCompositionImageEssenceDescriptorModel(); + + if (imageEssenceDescriptorModel != null) + { + imfErrorLogger.addAllErrors(imageEssenceDescriptorModel.getErrors()); + ApplicationTsp2121Composition.validateGenericPictureEssenceDescriptor(imageEssenceDescriptorModel, ApplicationCompositionType.APPLICATION_TSP_2121_COMPOSITION_TYPE, + imfErrorLogger); + ApplicationTsp2121Composition.validateImageCharacteristics(imageEssenceDescriptorModel, ApplicationCompositionType.APPLICATION_TSP_2121_COMPOSITION_TYPE, + imfErrorLogger); + } + } + catch (Exception e) { + imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("Exception in validating EssenceDescriptors in APPLICATION_TSP_2121_COMPOSITION_TYPE: %s ", e.getMessage())); + } + } + + public static void validateGenericPictureEssenceDescriptor(CompositionImageEssenceDescriptorModel imageEssenceDescriptorModel, + ApplicationCompositionFactory.ApplicationCompositionType applicationCompositionType, + IMFErrorLogger + imfErrorLogger) + { + UUID imageEssenceDescriptorID = imageEssenceDescriptorModel.getImageEssencedescriptorID(); + ColorModel colorModel = imageEssenceDescriptorModel.getColorModel(); + if( colorModel.equals(ColorModel.Unknown)) { + imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s has Invalid color components as per %s", + imageEssenceDescriptorID.toString(), applicationCompositionType.toString())); + return; + } + + Integer storedWidth = imageEssenceDescriptorModel.getStoredWidth(); + Integer storedHeight = imageEssenceDescriptorModel.getStoredHeight(); + if ((storedWidth <= 0) || (storedHeight <= 0)) { + imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s has invalid storedWidth(%d) or storedHeight(%d) as per %s", + imageEssenceDescriptorID.toString(), storedWidth, storedHeight, applicationCompositionType.toString())); + } + + Integer sampleWidth = imageEssenceDescriptorModel.getSampleWidth(); + Integer sampleHeight = imageEssenceDescriptorModel.getSampleHeight(); + if ((sampleWidth != null && !sampleWidth.equals(storedWidth)) || + (sampleHeight != null && !sampleHeight.equals(storedHeight))) { + imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s has invalid sampleWidth(%d) or sampleHeight(%d) as per %s", + imageEssenceDescriptorID.toString(), sampleWidth != null ? sampleWidth : 0, sampleHeight != null ? sampleHeight : 0, + applicationCompositionType.toString())); + } + + if( imageEssenceDescriptorModel.getStoredOffset() != null) { + imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s invalid StoredOffset as per %s", + imageEssenceDescriptorID.toString(), applicationCompositionType.toString())); + } + + ColorPrimaries colorPrimaries = imageEssenceDescriptorModel.getColorPrimaries(); + if(colorPrimaries.equals(ColorPrimaries.Unknown)) { + imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s has invalid ColorPrimaries as per %s", + imageEssenceDescriptorID.toString(), applicationCompositionType.toString())); + } + + TransferCharacteristic transferCharacteristic = imageEssenceDescriptorModel.getTransferCharacteristic(); + if(transferCharacteristic.equals(TransferCharacteristic.Unknown)) { + imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s has invalid TransferCharacteristic as per %s", + imageEssenceDescriptorID.toString(), applicationCompositionType.toString())); + } + + CodingEquation codingEquation = imageEssenceDescriptorModel.getCodingEquation(); + if(codingEquation.equals(CodingEquation.Unknown)) { + imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s has invalid CodingEquation as per %s", + imageEssenceDescriptorID.toString(), applicationCompositionType.toString())); + } + + Colorimetry color = imageEssenceDescriptorModel.getColor(); + if(color.equals(Colorimetry.Unknown)) { + imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s has invalid ColorPrimaries(%s)-TransferCharacteristic(%s)-CodingEquation(%s) combination as per %s", + imageEssenceDescriptorID.toString(), colorPrimaries.name(), transferCharacteristic.name(), codingEquation.name(), applicationCompositionType.toString())); + } + + FrameLayoutType frameLayoutType = imageEssenceDescriptorModel.getFrameLayoutType(); + UL essenceContainerFormatUL = imageEssenceDescriptorModel.getEssenceContainerFormatUL(); + if(essenceContainerFormatUL != null) { + Byte contentKind = essenceContainerFormatUL.getULAsBytes()[14]; + if ((frameLayoutType.equals(FrameLayoutType.FullFrame) && contentKind != 6) || + (frameLayoutType.equals(FrameLayoutType.SeparateFields) && contentKind != 3)) { + imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s has invalid ContentKind(%d) indicated by the ContainerFormat as per %s", + imageEssenceDescriptorID.toString(), contentKind, applicationCompositionType.toString())); + } + } + } + + public static void validateImageCharacteristics(CompositionImageEssenceDescriptorModel imageEssenceDescriptorModel, + ApplicationCompositionFactory.ApplicationCompositionType applicationCompositionType, + IMFErrorLogger imfErrorLogger) + { + UUID imageEssenceDescriptorID = imageEssenceDescriptorModel.getImageEssencedescriptorID(); + + ColorModel colorModel = imageEssenceDescriptorModel.getColorModel(); + if( !colorModel.equals(ColorModel.RGB) && !colorModel.equals(ColorModel.YUV)) { + imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s has Invalid color components as per %s", + imageEssenceDescriptorID.toString(), applicationCompositionType.toString())); + return; + } + + //storedWidth + Integer storedWidth = imageEssenceDescriptorModel.getStoredWidth(); + //storedHeight + Integer storedHeight = imageEssenceDescriptorModel.getStoredHeight(); + if (!resolutionsSupported.contains(new Fraction(storedWidth, storedHeight))) { + imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s has invalid storedHeight(%d) as per %s", + imageEssenceDescriptorID.toString(), storedHeight, applicationCompositionType.toString())); + } + + //ComponentDepth + Integer componentDepth = imageEssenceDescriptorModel.getComponentDepth(); + if (!bitDepthsSupported.contains(componentDepth)) { + imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s invalid ComponentDepth(%d) as per %s", + imageEssenceDescriptorID.toString(), componentDepth, applicationCompositionType.toString())); + } + + //PixelBitDepth + Integer pixelBitDepth = imageEssenceDescriptorModel.getPixelBitDepth(); + if (!bitDepthsSupported.contains(pixelBitDepth)) { + imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s invalid PixelBitDepth(%d) as per %s", + imageEssenceDescriptorID.toString(), pixelBitDepth, applicationCompositionType.toString())); + } + + //FrameLayout + FrameLayoutType frameLayoutType = imageEssenceDescriptorModel.getFrameLayoutType(); + if (!frameLayoutType.equals(FrameLayoutType.FullFrame) && !frameLayoutType.equals(FrameLayoutType.SeparateFields)) { + imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s has invalid FrameLayout(%s) as per %s", + imageEssenceDescriptorID.toString(), frameLayoutType.name(), applicationCompositionType.toString())); + } + else { + //SampleRate + Fraction sampleRate = imageEssenceDescriptorModel.getSampleRate(); + if (!sampleRateSupported.contains(sampleRate)) { + imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s has Invalid SampleRate(%s) for frame structure %s as per %s", + imageEssenceDescriptorID.toString(), sampleRate.toString(), frameLayoutType.name(), applicationCompositionType.toString())); + } + } + + //Sampling + Sampling sampling = imageEssenceDescriptorModel.getSampling(); + if(frameLayoutType.equals(FrameLayoutType.SeparateFields) && !sampling.equals(Sampling.Sampling422) ) { + imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s has invalid combination of FrameLayOut(%s) for Sampling(%s) as per %s", + imageEssenceDescriptorID.toString(), frameLayoutType.name(), sampling.name(), applicationCompositionType.toString())); + } + + //Quantization + Quantization quantization = imageEssenceDescriptorModel.getQuantization(); + Colorimetry color = imageEssenceDescriptorModel.getColor(); + if((sampling.equals(Sampling.Sampling422) && + !(quantization.equals(Quantization.QE1) && colorModel.equals(ColorModel.YUV))) || + (quantization.equals(Quantization.QE2) && + !(colorModel.equals(ColorModel.RGB) && color.equals(Colorimetry.Color3)))) { + imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s has invalid combination of quantization(%s)-Sampling(%s)-colorModel(%s)-color(%s) as per %s", + imageEssenceDescriptorID.toString(), quantization.name(), sampling.name(), colorModel.name(), color.name(), applicationCompositionType.toString())); + } + } + + public ApplicationCompositionType getApplicationCompositionType() { + return ApplicationCompositionType.APPLICATION_TSP_2121_COMPOSITION_TYPE; + } + +} From 2a97cf0a2e5a6a336efd42f1a28f5b1280bb0e11 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Arnaud Date: Mon, 7 Jan 2019 19:41:10 +0100 Subject: [PATCH 04/11] fix check ContainerFormat --- .../st2067_2/ApplicationTsp2121Composition.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/netflix/imflibrary/st2067_2/ApplicationTsp2121Composition.java b/src/main/java/com/netflix/imflibrary/st2067_2/ApplicationTsp2121Composition.java index 4fa824c4..09befef4 100644 --- a/src/main/java/com/netflix/imflibrary/st2067_2/ApplicationTsp2121Composition.java +++ b/src/main/java/com/netflix/imflibrary/st2067_2/ApplicationTsp2121Composition.java @@ -145,16 +145,14 @@ public static void validateGenericPictureEssenceDescriptor(CompositionImageEssen imageEssenceDescriptorID.toString(), colorPrimaries.name(), transferCharacteristic.name(), codingEquation.name(), applicationCompositionType.toString())); } - FrameLayoutType frameLayoutType = imageEssenceDescriptorModel.getFrameLayoutType(); UL essenceContainerFormatUL = imageEssenceDescriptorModel.getEssenceContainerFormatUL(); if(essenceContainerFormatUL != null) { - Byte contentKind = essenceContainerFormatUL.getULAsBytes()[14]; - if ((frameLayoutType.equals(FrameLayoutType.FullFrame) && contentKind != 6) || - (frameLayoutType.equals(FrameLayoutType.SeparateFields) && contentKind != 3)) { + UL proresUL = UL.fromULAsURNStringToUL("urn:smpte:ul:06.0E.2B.34.04.01.01.0D.0D.01.03.01.02.1C.01.00"); + if (!essenceContainerFormatUL.equals(proresUL)) { imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, - String.format("EssenceDescriptor with ID %s has invalid ContentKind(%d) indicated by the ContainerFormat as per %s", - imageEssenceDescriptorID.toString(), contentKind, applicationCompositionType.toString())); + String.format("EssenceDescriptor with ID %s has invalid UL %s indicated by the ContainerFormat as per %s", + imageEssenceDescriptorID.toString(), essenceContainerFormatUL.toString(), applicationCompositionType.toString())); } } } From 23363c6966f29d05b212d58c7f4fd214f38db355 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Arnaud Date: Wed, 16 Oct 2019 22:59:09 +0200 Subject: [PATCH 05/11] add copyright --- .../ApplicationTsp2121Composition.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/com/netflix/imflibrary/st2067_2/ApplicationTsp2121Composition.java b/src/main/java/com/netflix/imflibrary/st2067_2/ApplicationTsp2121Composition.java index 09befef4..e7ad0b3c 100644 --- a/src/main/java/com/netflix/imflibrary/st2067_2/ApplicationTsp2121Composition.java +++ b/src/main/java/com/netflix/imflibrary/st2067_2/ApplicationTsp2121Composition.java @@ -1,3 +1,21 @@ +/* + * + * Copyright 2015 Media-IO, France. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.netflix.imflibrary.st2067_2; import com.netflix.imflibrary.Colorimetry; From 9a55587edd9c0b30c624944bebeac42a028c7141 Mon Sep 17 00:00:00 2001 From: Valentin NOEL Date: Wed, 12 Feb 2020 10:46:52 +0100 Subject: [PATCH 06/11] Move the ApplicationTsp2121Composition class to a new tsp_2121 package --- .../ApplicationCompositionFactory.java | 2 +- .../st2067_2/IMFCompositionPlaylistType.java | 2 +- .../ApplicationTsp2121Composition.java | 95 ++++++++++--------- 3 files changed, 52 insertions(+), 47 deletions(-) rename src/main/java/com/netflix/imflibrary/{st2067_2 => tsp_2121}/ApplicationTsp2121Composition.java (82%) diff --git a/src/main/java/com/netflix/imflibrary/st2067_2/ApplicationCompositionFactory.java b/src/main/java/com/netflix/imflibrary/st2067_2/ApplicationCompositionFactory.java index 6334329f..95711617 100755 --- a/src/main/java/com/netflix/imflibrary/st2067_2/ApplicationCompositionFactory.java +++ b/src/main/java/com/netflix/imflibrary/st2067_2/ApplicationCompositionFactory.java @@ -20,10 +20,10 @@ import com.netflix.imflibrary.IMFErrorLogger; import com.netflix.imflibrary.exceptions.IMFException; +import com.netflix.imflibrary.tsp_2121.ApplicationTsp2121Composition; import com.netflix.imflibrary.utils.FileByteRangeProvider; import com.netflix.imflibrary.utils.ResourceByteRangeProvider; -import javax.annotation.Nullable; import java.io.File; import java.io.IOException; import java.lang.reflect.Constructor; diff --git a/src/main/java/com/netflix/imflibrary/st2067_2/IMFCompositionPlaylistType.java b/src/main/java/com/netflix/imflibrary/st2067_2/IMFCompositionPlaylistType.java index b477f493..6cbe1d30 100644 --- a/src/main/java/com/netflix/imflibrary/st2067_2/IMFCompositionPlaylistType.java +++ b/src/main/java/com/netflix/imflibrary/st2067_2/IMFCompositionPlaylistType.java @@ -54,7 +54,7 @@ * A class that models an IMF Composition Playlist structure. */ @Immutable -final class IMFCompositionPlaylistType { +public final class IMFCompositionPlaylistType { private final UUID id; private final Composition.EditRate editRate; private final String annotation; diff --git a/src/main/java/com/netflix/imflibrary/st2067_2/ApplicationTsp2121Composition.java b/src/main/java/com/netflix/imflibrary/tsp_2121/ApplicationTsp2121Composition.java similarity index 82% rename from src/main/java/com/netflix/imflibrary/st2067_2/ApplicationTsp2121Composition.java rename to src/main/java/com/netflix/imflibrary/tsp_2121/ApplicationTsp2121Composition.java index e7ad0b3c..fb249d50 100644 --- a/src/main/java/com/netflix/imflibrary/st2067_2/ApplicationTsp2121Composition.java +++ b/src/main/java/com/netflix/imflibrary/tsp_2121/ApplicationTsp2121Composition.java @@ -16,12 +16,15 @@ * */ -package com.netflix.imflibrary.st2067_2; +package com.netflix.imflibrary.tsp_2121; import com.netflix.imflibrary.Colorimetry; import com.netflix.imflibrary.IMFErrorLogger; import com.netflix.imflibrary.st0377.header.UL; +import com.netflix.imflibrary.st2067_2.AbstractApplicationComposition; import com.netflix.imflibrary.st2067_2.ApplicationCompositionFactory.ApplicationCompositionType; +import com.netflix.imflibrary.st2067_2.CompositionImageEssenceDescriptorModel; +import com.netflix.imflibrary.st2067_2.IMFCompositionPlaylistType; import com.netflix.imflibrary.utils.Fraction; import javax.annotation.Nonnull; @@ -30,25 +33,35 @@ import java.util.Set; import java.util.UUID; -import static com.netflix.imflibrary.Colorimetry.CodingEquation; -import static com.netflix.imflibrary.Colorimetry.ColorModel; -import static com.netflix.imflibrary.Colorimetry.ColorPrimaries; -import static com.netflix.imflibrary.Colorimetry.Quantization; -import static com.netflix.imflibrary.Colorimetry.Sampling; -import static com.netflix.imflibrary.Colorimetry.TransferCharacteristic; +import static com.netflix.imflibrary.Colorimetry.*; import static com.netflix.imflibrary.st0377.header.GenericPictureEssenceDescriptor.FrameLayoutType; /** * A class that models Composition with Application TSP 2121 constraints from TSP 2121-1 specification */ public class ApplicationTsp2121Composition extends AbstractApplicationComposition { - public static final SetresolutionsSupported = Collections.unmodifiableSet(new HashSet() {{ - add(new Fraction(1920, 1080)); add(new Fraction(3840, 2160)); }}); - public static final SetsampleRateSupported = Collections.unmodifiableSet(new HashSet() {{ - add(new Fraction(24)); add(new Fraction(25)); add(new Fraction(30)); add(new Fraction(50)); add(new Fraction(60)); - add(new Fraction(24000, 1001)); add(new Fraction(30000, 1001)); add(new Fraction(60000, 1001)); }}); - public static final SetbitDepthsSupported = Collections.unmodifiableSet(new HashSet() {{ - add(10); add(12); }}); + + public static final Set resolutionsSupported = Collections.unmodifiableSet(new HashSet() {{ + add(new Fraction(1920, 1080)); + add(new Fraction(3840, 2160)); + }}); + + public static final Set sampleRateSupported = Collections.unmodifiableSet(new HashSet() {{ + add(new Fraction(24)); + add(new Fraction(25)); + add(new Fraction(30)); + add(new Fraction(50)); + add(new Fraction(60)); + add(new Fraction(24000, 1001)); + add(new Fraction(30000, 1001)); + add(new Fraction(60000, 1001)); + }}); + + public static final Set bitDepthsSupported = Collections.unmodifiableSet(new HashSet() {{ + add(10); + add(12); + }}); + private static final Set ignoreSet = Collections.unmodifiableSet(new HashSet() {{ add("SignalStandard"); add("ActiveFormatDescriptor"); @@ -66,37 +79,31 @@ public ApplicationTsp2121Composition(@Nonnull IMFCompositionPlaylistType imfComp } public ApplicationTsp2121Composition(@Nonnull IMFCompositionPlaylistType imfCompositionPlaylistType, Set homogeneitySelectionSet) { - super(imfCompositionPlaylistType, ignoreSet, homogeneitySelectionSet); - try - { + try { CompositionImageEssenceDescriptorModel imageEssenceDescriptorModel = getCompositionImageEssenceDescriptorModel(); - if (imageEssenceDescriptorModel != null) - { + if (imageEssenceDescriptorModel != null) { imfErrorLogger.addAllErrors(imageEssenceDescriptorModel.getErrors()); - ApplicationTsp2121Composition.validateGenericPictureEssenceDescriptor(imageEssenceDescriptorModel, ApplicationCompositionType.APPLICATION_TSP_2121_COMPOSITION_TYPE, + validateGenericPictureEssenceDescriptor(imageEssenceDescriptorModel, ApplicationCompositionType.APPLICATION_TSP_2121_COMPOSITION_TYPE, imfErrorLogger); - ApplicationTsp2121Composition.validateImageCharacteristics(imageEssenceDescriptorModel, ApplicationCompositionType.APPLICATION_TSP_2121_COMPOSITION_TYPE, + validateImageCharacteristics(imageEssenceDescriptorModel, ApplicationCompositionType.APPLICATION_TSP_2121_COMPOSITION_TYPE, imfErrorLogger); } - } - catch (Exception e) { + } catch (Exception e) { imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("Exception in validating EssenceDescriptors in APPLICATION_TSP_2121_COMPOSITION_TYPE: %s ", e.getMessage())); } } - public static void validateGenericPictureEssenceDescriptor(CompositionImageEssenceDescriptorModel imageEssenceDescriptorModel, - ApplicationCompositionFactory.ApplicationCompositionType applicationCompositionType, - IMFErrorLogger - imfErrorLogger) - { + private static void validateGenericPictureEssenceDescriptor(CompositionImageEssenceDescriptorModel imageEssenceDescriptorModel, + ApplicationCompositionType applicationCompositionType, + IMFErrorLogger imfErrorLogger) { UUID imageEssenceDescriptorID = imageEssenceDescriptorModel.getImageEssencedescriptorID(); ColorModel colorModel = imageEssenceDescriptorModel.getColorModel(); - if( colorModel.equals(ColorModel.Unknown)) { + if (colorModel.equals(ColorModel.Unknown)) { imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s has Invalid color components as per %s", @@ -124,7 +131,7 @@ public static void validateGenericPictureEssenceDescriptor(CompositionImageEssen applicationCompositionType.toString())); } - if( imageEssenceDescriptorModel.getStoredOffset() != null) { + if (imageEssenceDescriptorModel.getStoredOffset() != null) { imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s invalid StoredOffset as per %s", @@ -132,7 +139,7 @@ public static void validateGenericPictureEssenceDescriptor(CompositionImageEssen } ColorPrimaries colorPrimaries = imageEssenceDescriptorModel.getColorPrimaries(); - if(colorPrimaries.equals(ColorPrimaries.Unknown)) { + if (colorPrimaries.equals(ColorPrimaries.Unknown)) { imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s has invalid ColorPrimaries as per %s", @@ -140,7 +147,7 @@ public static void validateGenericPictureEssenceDescriptor(CompositionImageEssen } TransferCharacteristic transferCharacteristic = imageEssenceDescriptorModel.getTransferCharacteristic(); - if(transferCharacteristic.equals(TransferCharacteristic.Unknown)) { + if (transferCharacteristic.equals(TransferCharacteristic.Unknown)) { imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s has invalid TransferCharacteristic as per %s", @@ -148,7 +155,7 @@ public static void validateGenericPictureEssenceDescriptor(CompositionImageEssen } CodingEquation codingEquation = imageEssenceDescriptorModel.getCodingEquation(); - if(codingEquation.equals(CodingEquation.Unknown)) { + if (codingEquation.equals(CodingEquation.Unknown)) { imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s has invalid CodingEquation as per %s", @@ -156,7 +163,7 @@ public static void validateGenericPictureEssenceDescriptor(CompositionImageEssen } Colorimetry color = imageEssenceDescriptorModel.getColor(); - if(color.equals(Colorimetry.Unknown)) { + if (color.equals(Colorimetry.Unknown)) { imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s has invalid ColorPrimaries(%s)-TransferCharacteristic(%s)-CodingEquation(%s) combination as per %s", @@ -164,7 +171,7 @@ public static void validateGenericPictureEssenceDescriptor(CompositionImageEssen } UL essenceContainerFormatUL = imageEssenceDescriptorModel.getEssenceContainerFormatUL(); - if(essenceContainerFormatUL != null) { + if (essenceContainerFormatUL != null) { UL proresUL = UL.fromULAsURNStringToUL("urn:smpte:ul:06.0E.2B.34.04.01.01.0D.0D.01.03.01.02.1C.01.00"); if (!essenceContainerFormatUL.equals(proresUL)) { imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, @@ -173,16 +180,15 @@ public static void validateGenericPictureEssenceDescriptor(CompositionImageEssen imageEssenceDescriptorID.toString(), essenceContainerFormatUL.toString(), applicationCompositionType.toString())); } } - } + } - public static void validateImageCharacteristics(CompositionImageEssenceDescriptorModel imageEssenceDescriptorModel, - ApplicationCompositionFactory.ApplicationCompositionType applicationCompositionType, - IMFErrorLogger imfErrorLogger) - { + private static void validateImageCharacteristics(CompositionImageEssenceDescriptorModel imageEssenceDescriptorModel, + ApplicationCompositionType applicationCompositionType, + IMFErrorLogger imfErrorLogger) { UUID imageEssenceDescriptorID = imageEssenceDescriptorModel.getImageEssencedescriptorID(); ColorModel colorModel = imageEssenceDescriptorModel.getColorModel(); - if( !colorModel.equals(ColorModel.RGB) && !colorModel.equals(ColorModel.YUV)) { + if (!colorModel.equals(ColorModel.RGB) && !colorModel.equals(ColorModel.YUV)) { imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s has Invalid color components as per %s", @@ -226,8 +232,7 @@ public static void validateImageCharacteristics(CompositionImageEssenceDescripto IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s has invalid FrameLayout(%s) as per %s", imageEssenceDescriptorID.toString(), frameLayoutType.name(), applicationCompositionType.toString())); - } - else { + } else { //SampleRate Fraction sampleRate = imageEssenceDescriptorModel.getSampleRate(); if (!sampleRateSupported.contains(sampleRate)) { @@ -240,7 +245,7 @@ public static void validateImageCharacteristics(CompositionImageEssenceDescripto //Sampling Sampling sampling = imageEssenceDescriptorModel.getSampling(); - if(frameLayoutType.equals(FrameLayoutType.SeparateFields) && !sampling.equals(Sampling.Sampling422) ) { + if (frameLayoutType.equals(FrameLayoutType.SeparateFields) && !sampling.equals(Sampling.Sampling422)) { imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s has invalid combination of FrameLayOut(%s) for Sampling(%s) as per %s", @@ -250,7 +255,7 @@ public static void validateImageCharacteristics(CompositionImageEssenceDescripto //Quantization Quantization quantization = imageEssenceDescriptorModel.getQuantization(); Colorimetry color = imageEssenceDescriptorModel.getColor(); - if((sampling.equals(Sampling.Sampling422) && + if ((sampling.equals(Sampling.Sampling422) && !(quantization.equals(Quantization.QE1) && colorModel.equals(ColorModel.YUV))) || (quantization.equals(Quantization.QE2) && !(colorModel.equals(ColorModel.RGB) && color.equals(Colorimetry.Color3)))) { From 25687b49768fcd82cccc1ac1a688e5e0a19cf847 Mon Sep 17 00:00:00 2001 From: Valentin NOEL Date: Wed, 12 Feb 2020 10:49:56 +0100 Subject: [PATCH 07/11] Rename Color.8 enum value --- src/main/java/com/netflix/imflibrary/Colorimetry.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/netflix/imflibrary/Colorimetry.java b/src/main/java/com/netflix/imflibrary/Colorimetry.java index 0aa22eb3..69c74e57 100644 --- a/src/main/java/com/netflix/imflibrary/Colorimetry.java +++ b/src/main/java/com/netflix/imflibrary/Colorimetry.java @@ -22,7 +22,7 @@ public enum Colorimetry { Color6(ColorPrimaries.P3D65, TransferCharacteristic.SMPTEST2084, CodingEquation.None), Color7(ColorPrimaries.ITU2020, TransferCharacteristic.SMPTEST2084, CodingEquation.ITU2020NCL), Color_App5_AP0(ColorPrimaries.ACES, TransferCharacteristic.Linear, CodingEquation.None), - Color8DPP(ColorPrimaries.ITU2020, TransferCharacteristic.ITU2020HLG, CodingEquation.ITU2020NCL), + Color8(ColorPrimaries.ITU2020, TransferCharacteristic.ITU2020HLG, CodingEquation.ITU2020NCL), Unknown(ColorPrimaries.Unknown, TransferCharacteristic.Unknown, CodingEquation.Unknown); From a63699b922c1a63f8a355d9d6c07fe7c745d6a3a Mon Sep 17 00:00:00 2001 From: Valentin NOEL Date: Wed, 12 Feb 2020 11:39:29 +0100 Subject: [PATCH 08/11] Add specialized CompositionImageEssenceDescriptorModel for TSP 2121 --- ...ompositionImageEssenceDescriptorModel.java | 16 ++- ...ionImageEssenceTsp2121DescriptorModel.java | 128 ++++++++++++++++++ 2 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/netflix/imflibrary/tsp_2121/CompositionImageEssenceTsp2121DescriptorModel.java diff --git a/src/main/java/com/netflix/imflibrary/st2067_2/CompositionImageEssenceDescriptorModel.java b/src/main/java/com/netflix/imflibrary/st2067_2/CompositionImageEssenceDescriptorModel.java index 986297b9..0ee917bb 100644 --- a/src/main/java/com/netflix/imflibrary/st2067_2/CompositionImageEssenceDescriptorModel.java +++ b/src/main/java/com/netflix/imflibrary/st2067_2/CompositionImageEssenceDescriptorModel.java @@ -29,7 +29,7 @@ /** * Created by svenkatrav on 11/2/16. */ -public final class CompositionImageEssenceDescriptorModel { +public class CompositionImageEssenceDescriptorModel { private final UUID imageEssencedescriptorID; private final DOMNodeObjectModel imageEssencedescriptorDOMNode; private final RegXMLLibDictionary regXMLLibDictionary; @@ -199,6 +199,18 @@ public CompositionImageEssenceDescriptorModel(@Nonnull UUID imageEssencedescript return imageEssencedescriptorID; } + protected @Nonnull IMFErrorLogger getImfErrorLogger() { + return imfErrorLogger; + } + + protected @Nonnull DOMNodeObjectModel getImageEssenceDescriptorDOMNode() { + return imageEssencedescriptorDOMNode; + } + + protected @Nonnull RegXMLLibDictionary getRegXMLLibDictionary() { + return regXMLLibDictionary; + } + public @Nonnull FrameLayoutType getFrameLayoutType() { return frameLayoutType; } @@ -380,7 +392,7 @@ public TransferCharacteristic getTransferCharacteristic() { return paletteLayout; } - private @Nonnull Integer parsePixelBitDepth(@Nonnull ColorModel colorModel) { + protected @Nonnull Integer parsePixelBitDepth(@Nonnull ColorModel colorModel) { Integer refPixelBitDepth = null; DOMNodeObjectModel subDescriptors = imageEssencedescriptorDOMNode.getDOMNode(regXMLLibDictionary.getSymbolNameFromURN(subdescriptorsUL)); if (subDescriptors == null) { diff --git a/src/main/java/com/netflix/imflibrary/tsp_2121/CompositionImageEssenceTsp2121DescriptorModel.java b/src/main/java/com/netflix/imflibrary/tsp_2121/CompositionImageEssenceTsp2121DescriptorModel.java new file mode 100644 index 00000000..cf1dd028 --- /dev/null +++ b/src/main/java/com/netflix/imflibrary/tsp_2121/CompositionImageEssenceTsp2121DescriptorModel.java @@ -0,0 +1,128 @@ +package com.netflix.imflibrary.tsp_2121; + +import com.netflix.imflibrary.Colorimetry; +import com.netflix.imflibrary.IMFErrorLogger; +import com.netflix.imflibrary.st2067_2.CompositionImageEssenceDescriptorModel; +import com.netflix.imflibrary.utils.DOMNodeObjectModel; +import com.netflix.imflibrary.utils.RegXMLLibDictionary; + +import javax.annotation.Nonnull; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import static com.netflix.imflibrary.st0377.header.GenericPictureEssenceDescriptor.*; +import static com.netflix.imflibrary.st0377.header.GenericPictureEssenceDescriptor.RGBAComponentType.Null; + + +public final class CompositionImageEssenceTsp2121DescriptorModel extends CompositionImageEssenceDescriptorModel { + + public CompositionImageEssenceTsp2121DescriptorModel(@Nonnull UUID imageEssenceDescriptorID, + @Nonnull DOMNodeObjectModel imageEssenceDescriptorDOMNode, + @Nonnull RegXMLLibDictionary regXMLLibDictionary) { + super(imageEssenceDescriptorID, imageEssenceDescriptorDOMNode, regXMLLibDictionary); + } + + @Override + protected @Nonnull Integer parsePixelBitDepth(@Nonnull Colorimetry.ColorModel colorModel) { + Integer refPixelBitDepth = null; + DOMNodeObjectModel subDescriptors = getImageEssenceDescriptorDOMNode().getDOMNode(getRegXMLLibDictionary().getSymbolNameFromURN(subdescriptorsUL)); + if (subDescriptors == null) { + Integer componentDepth = getComponentDepth(); + if (componentDepth == null || componentDepth == 0) { + getImfErrorLogger().addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s is missing SubDescriptors and missing Component Depth", getImageEssencedescriptorID().toString())); + } + refPixelBitDepth = componentDepth; + } else { + DOMNodeObjectModel jpeg2000SubdescriptorDOMNode = subDescriptors.getDOMNode(getRegXMLLibDictionary().getSymbolNameFromURN(jpeg2000SubDescriptorUL)); + + if (jpeg2000SubdescriptorDOMNode == null) { + getImfErrorLogger().addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s is missing JPEG2000SubDescriptor in SubDescriptors", + getImageEssencedescriptorID().toString())); + } else { + DOMNodeObjectModel j2cLayout = jpeg2000SubdescriptorDOMNode.getDOMNode(getRegXMLLibDictionary().getSymbolNameFromURN(j2cLayoutUL)); + if (j2cLayout == null) { + getImfErrorLogger().addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s is missing J2CLayout in JPEG2000SubDescriptor", + getImageEssencedescriptorID().toString())); + } else { + List rgbaComponents = j2cLayout.getDOMNodes(getRegXMLLibDictionary().getSymbolNameFromURN(rgbaComponentUL)); + if (rgbaComponents.size() == 0) { + getImfErrorLogger().addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s is missing RGBAComponent in J2CLayout", + getImageEssencedescriptorID().toString())); + } else { + Map componentMap = new HashMap<>(); + for (DOMNodeObjectModel domNodeObjectModel : rgbaComponents) { + String code = domNodeObjectModel.getFieldAsString(getRegXMLLibDictionary().getTypeFieldNameFromURN(rgbaComponentUL, codeUL)); + if (code == null) { + getImfErrorLogger().addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s has an RGBAComponent with missing Code", + getImageEssencedescriptorID().toString())); + } else { + RGBAComponentType codeValue = RGBAComponentType.valueOf(getRegXMLLibDictionary().getEnumerationValueFromName(rgbaComponentKindUL, code)); + Integer pixelBitDepth = domNodeObjectModel.getFieldAsInteger(getRegXMLLibDictionary().getTypeFieldNameFromURN(rgbaComponentUL, componentSizeUL)); + if (pixelBitDepth == null) { + getImfErrorLogger().addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s has an RGBAComponent %s with missing ComponentSize", + getImageEssencedescriptorID().toString(), code)); + } else { + if (refPixelBitDepth == null) { + refPixelBitDepth = pixelBitDepth; + } + if ((codeValue.equals(Null) && pixelBitDepth != 0) || + (!codeValue.equals(Null) && (!pixelBitDepth.equals(refPixelBitDepth)))) { + getImfErrorLogger().addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s has an RGBAComponent %s with invalid ComponentSize %d", + getImageEssencedescriptorID().toString(), code, pixelBitDepth)); + } + } + if (componentMap.containsKey(codeValue)) { + Integer count = componentMap.get(codeValue); + componentMap.put(codeValue, count + 1); + } else { + componentMap.put(codeValue, 1); + } + + } + } + componentMap.entrySet().stream().forEach( + e -> { + if (e.getKey().equals(RGBAComponentType.Null)) { + if (!e.getValue().equals(5)) { + getImfErrorLogger().addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s and ColorModel %s has invalid number of RGBAComponent %s in J2CLayout", + getImageEssencedescriptorID().toString(), colorModel.name(), e.getKey())); + } + } else if (!colorModel.getComponentTypeSet().contains(e.getKey())) { + getImfErrorLogger().addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s and ColorModel %s has invalid RGBAComponent %s in J2CLayout", + getImageEssencedescriptorID().toString(), colorModel.name(), e.getKey())); + } else if (!e.getValue().equals(1)) { + getImfErrorLogger().addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s and ColorModel %s has more than one RGBAComponent %s in J2CLayout", + getImageEssencedescriptorID().toString(), colorModel.name(), e.getKey())); + } + + } + ); + } + } + } + } + return refPixelBitDepth != null ? refPixelBitDepth : 0; + } +} From 58ae00eb513f651dd29c5ffa164a71bb58895395 Mon Sep 17 00:00:00 2001 From: Valentin NOEL Date: Wed, 12 Feb 2020 11:40:50 +0100 Subject: [PATCH 09/11] Revert CompositionImageEssenceDescriptorModel subdescriptor check on pixel bit depth parsing --- .../CompositionImageEssenceDescriptorModel.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/netflix/imflibrary/st2067_2/CompositionImageEssenceDescriptorModel.java b/src/main/java/com/netflix/imflibrary/st2067_2/CompositionImageEssenceDescriptorModel.java index 0ee917bb..f971a016 100644 --- a/src/main/java/com/netflix/imflibrary/st2067_2/CompositionImageEssenceDescriptorModel.java +++ b/src/main/java/com/netflix/imflibrary/st2067_2/CompositionImageEssenceDescriptorModel.java @@ -396,13 +396,10 @@ public TransferCharacteristic getTransferCharacteristic() { Integer refPixelBitDepth = null; DOMNodeObjectModel subDescriptors = imageEssencedescriptorDOMNode.getDOMNode(regXMLLibDictionary.getSymbolNameFromURN(subdescriptorsUL)); if (subDescriptors == null) { - Integer componentDepth = getComponentDepth(); - if (componentDepth == 0) { - imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, - IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, - String.format("EssenceDescriptor with ID %s is missing SubDescriptors and missing Component Depth", imageEssencedescriptorID.toString())); - } - refPixelBitDepth = componentDepth; + imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, + IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, + String.format("EssenceDescriptor with ID %s is missing SubDescriptors", imageEssencedescriptorID.toString())); + } else { DOMNodeObjectModel jpeg2000SubdescriptorDOMNode = subDescriptors.getDOMNode(regXMLLibDictionary.getSymbolNameFromURN(jpeg2000SubDescriptorUL)); From 63932e1b4995d4d437f32a0680a2b1190595c4ae Mon Sep 17 00:00:00 2001 From: Valentin NOEL Date: Wed, 12 Feb 2020 11:44:22 +0100 Subject: [PATCH 10/11] ApplicationTsp2121Composition handles the new CompositionImageEssenceTsp2121DescriptorModel And a little refactoring --- .../AbstractApplicationComposition.java | 2 +- .../ApplicationTsp2121Composition.java | 72 +++++++++++-------- 2 files changed, 45 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/netflix/imflibrary/st2067_2/AbstractApplicationComposition.java b/src/main/java/com/netflix/imflibrary/st2067_2/AbstractApplicationComposition.java index 68ed1913..eb7e185c 100644 --- a/src/main/java/com/netflix/imflibrary/st2067_2/AbstractApplicationComposition.java +++ b/src/main/java/com/netflix/imflibrary/st2067_2/AbstractApplicationComposition.java @@ -646,7 +646,7 @@ Map getEssenceDescriptorListMap(Set ignoreSet) * * @return a HashMap mapping the UUID to its corresponding EssenceDescriptor in the Composition */ - Map getEssenceDescriptorListMap() { + protected Map getEssenceDescriptorListMap() { return getEssenceDescriptorListMap(new HashSet<>()); } diff --git a/src/main/java/com/netflix/imflibrary/tsp_2121/ApplicationTsp2121Composition.java b/src/main/java/com/netflix/imflibrary/tsp_2121/ApplicationTsp2121Composition.java index fb249d50..fb168319 100644 --- a/src/main/java/com/netflix/imflibrary/tsp_2121/ApplicationTsp2121Composition.java +++ b/src/main/java/com/netflix/imflibrary/tsp_2121/ApplicationTsp2121Composition.java @@ -25,9 +25,11 @@ import com.netflix.imflibrary.st2067_2.ApplicationCompositionFactory.ApplicationCompositionType; import com.netflix.imflibrary.st2067_2.CompositionImageEssenceDescriptorModel; import com.netflix.imflibrary.st2067_2.IMFCompositionPlaylistType; +import com.netflix.imflibrary.utils.DOMNodeObjectModel; import com.netflix.imflibrary.utils.Fraction; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.Collections; import java.util.HashSet; import java.util.Set; @@ -74,6 +76,8 @@ public class ApplicationTsp2121Composition extends AbstractApplicationCompositio add("ActiveYOffset"); }}); + private CompositionImageEssenceTsp2121DescriptorModel imageEssenceDescriptorModel; + public ApplicationTsp2121Composition(@Nonnull IMFCompositionPlaylistType imfCompositionPlaylistType) { this(imfCompositionPlaylistType, new HashSet<>()); } @@ -82,14 +86,12 @@ public ApplicationTsp2121Composition(@Nonnull IMFCompositionPlaylistType imfComp super(imfCompositionPlaylistType, ignoreSet, homogeneitySelectionSet); try { - CompositionImageEssenceDescriptorModel imageEssenceDescriptorModel = getCompositionImageEssenceDescriptorModel(); + this.imageEssenceDescriptorModel = (CompositionImageEssenceTsp2121DescriptorModel) getCompositionImageEssenceDescriptorModel(); if (imageEssenceDescriptorModel != null) { imfErrorLogger.addAllErrors(imageEssenceDescriptorModel.getErrors()); - validateGenericPictureEssenceDescriptor(imageEssenceDescriptorModel, ApplicationCompositionType.APPLICATION_TSP_2121_COMPOSITION_TYPE, - imfErrorLogger); - validateImageCharacteristics(imageEssenceDescriptorModel, ApplicationCompositionType.APPLICATION_TSP_2121_COMPOSITION_TYPE, - imfErrorLogger); + validateGenericPictureEssenceDescriptor(imfErrorLogger); + validateImageCharacteristics(imfErrorLogger); } } catch (Exception e) { imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, @@ -98,16 +100,32 @@ public ApplicationTsp2121Composition(@Nonnull IMFCompositionPlaylistType imfComp } } - private static void validateGenericPictureEssenceDescriptor(CompositionImageEssenceDescriptorModel imageEssenceDescriptorModel, - ApplicationCompositionType applicationCompositionType, - IMFErrorLogger imfErrorLogger) { + @Override + public @Nullable CompositionImageEssenceDescriptorModel getCompositionImageEssenceDescriptorModel() { + CompositionImageEssenceTsp2121DescriptorModel imageEssenceDescriptorModel = null; + final DOMNodeObjectModel imageEssencedescriptorDOMNode = this.getEssenceDescriptor( + this.getVideoVirtualTrack().getTrackResourceIds().iterator().next()); + + if (imageEssencedescriptorDOMNode != null) { + final UUID imageEssenceDescriptorID = getEssenceDescriptorListMap().entrySet().stream() + .filter(e -> e.getValue().equals(imageEssencedescriptorDOMNode)) + .map(e -> e.getKey()) + .findFirst().get(); + imageEssenceDescriptorModel = + new CompositionImageEssenceTsp2121DescriptorModel(imageEssenceDescriptorID, imageEssencedescriptorDOMNode, regXMLLibDictionary); + } + + return imageEssenceDescriptorModel; + } + + private void validateGenericPictureEssenceDescriptor(IMFErrorLogger imfErrorLogger) { UUID imageEssenceDescriptorID = imageEssenceDescriptorModel.getImageEssencedescriptorID(); ColorModel colorModel = imageEssenceDescriptorModel.getColorModel(); if (colorModel.equals(ColorModel.Unknown)) { imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s has Invalid color components as per %s", - imageEssenceDescriptorID.toString(), applicationCompositionType.toString())); + imageEssenceDescriptorID.toString(), getApplicationCompositionType().toString())); return; } @@ -117,7 +135,7 @@ private static void validateGenericPictureEssenceDescriptor(CompositionImageEsse imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s has invalid storedWidth(%d) or storedHeight(%d) as per %s", - imageEssenceDescriptorID.toString(), storedWidth, storedHeight, applicationCompositionType.toString())); + imageEssenceDescriptorID.toString(), storedWidth, storedHeight, getApplicationCompositionType().toString())); } Integer sampleWidth = imageEssenceDescriptorModel.getSampleWidth(); @@ -128,14 +146,14 @@ private static void validateGenericPictureEssenceDescriptor(CompositionImageEsse IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s has invalid sampleWidth(%d) or sampleHeight(%d) as per %s", imageEssenceDescriptorID.toString(), sampleWidth != null ? sampleWidth : 0, sampleHeight != null ? sampleHeight : 0, - applicationCompositionType.toString())); + getApplicationCompositionType().toString())); } if (imageEssenceDescriptorModel.getStoredOffset() != null) { imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s invalid StoredOffset as per %s", - imageEssenceDescriptorID.toString(), applicationCompositionType.toString())); + imageEssenceDescriptorID.toString(), getApplicationCompositionType().toString())); } ColorPrimaries colorPrimaries = imageEssenceDescriptorModel.getColorPrimaries(); @@ -143,7 +161,7 @@ private static void validateGenericPictureEssenceDescriptor(CompositionImageEsse imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s has invalid ColorPrimaries as per %s", - imageEssenceDescriptorID.toString(), applicationCompositionType.toString())); + imageEssenceDescriptorID.toString(), getApplicationCompositionType().toString())); } TransferCharacteristic transferCharacteristic = imageEssenceDescriptorModel.getTransferCharacteristic(); @@ -151,7 +169,7 @@ private static void validateGenericPictureEssenceDescriptor(CompositionImageEsse imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s has invalid TransferCharacteristic as per %s", - imageEssenceDescriptorID.toString(), applicationCompositionType.toString())); + imageEssenceDescriptorID.toString(), getApplicationCompositionType().toString())); } CodingEquation codingEquation = imageEssenceDescriptorModel.getCodingEquation(); @@ -159,7 +177,7 @@ private static void validateGenericPictureEssenceDescriptor(CompositionImageEsse imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s has invalid CodingEquation as per %s", - imageEssenceDescriptorID.toString(), applicationCompositionType.toString())); + imageEssenceDescriptorID.toString(), getApplicationCompositionType().toString())); } Colorimetry color = imageEssenceDescriptorModel.getColor(); @@ -167,7 +185,7 @@ private static void validateGenericPictureEssenceDescriptor(CompositionImageEsse imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s has invalid ColorPrimaries(%s)-TransferCharacteristic(%s)-CodingEquation(%s) combination as per %s", - imageEssenceDescriptorID.toString(), colorPrimaries.name(), transferCharacteristic.name(), codingEquation.name(), applicationCompositionType.toString())); + imageEssenceDescriptorID.toString(), colorPrimaries.name(), transferCharacteristic.name(), codingEquation.name(), getApplicationCompositionType().toString())); } UL essenceContainerFormatUL = imageEssenceDescriptorModel.getEssenceContainerFormatUL(); @@ -177,14 +195,12 @@ private static void validateGenericPictureEssenceDescriptor(CompositionImageEsse imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s has invalid UL %s indicated by the ContainerFormat as per %s", - imageEssenceDescriptorID.toString(), essenceContainerFormatUL.toString(), applicationCompositionType.toString())); + imageEssenceDescriptorID.toString(), essenceContainerFormatUL.toString(), getApplicationCompositionType().toString())); } } } - private static void validateImageCharacteristics(CompositionImageEssenceDescriptorModel imageEssenceDescriptorModel, - ApplicationCompositionType applicationCompositionType, - IMFErrorLogger imfErrorLogger) { + private void validateImageCharacteristics(IMFErrorLogger imfErrorLogger) { UUID imageEssenceDescriptorID = imageEssenceDescriptorModel.getImageEssencedescriptorID(); ColorModel colorModel = imageEssenceDescriptorModel.getColorModel(); @@ -192,7 +208,7 @@ private static void validateImageCharacteristics(CompositionImageEssenceDescript imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s has Invalid color components as per %s", - imageEssenceDescriptorID.toString(), applicationCompositionType.toString())); + imageEssenceDescriptorID.toString(), getApplicationCompositionType().toString())); return; } @@ -204,7 +220,7 @@ private static void validateImageCharacteristics(CompositionImageEssenceDescript imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s has invalid storedHeight(%d) as per %s", - imageEssenceDescriptorID.toString(), storedHeight, applicationCompositionType.toString())); + imageEssenceDescriptorID.toString(), storedHeight, getApplicationCompositionType().toString())); } //ComponentDepth @@ -213,7 +229,7 @@ private static void validateImageCharacteristics(CompositionImageEssenceDescript imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s invalid ComponentDepth(%d) as per %s", - imageEssenceDescriptorID.toString(), componentDepth, applicationCompositionType.toString())); + imageEssenceDescriptorID.toString(), componentDepth, getApplicationCompositionType().toString())); } //PixelBitDepth @@ -222,7 +238,7 @@ private static void validateImageCharacteristics(CompositionImageEssenceDescript imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s invalid PixelBitDepth(%d) as per %s", - imageEssenceDescriptorID.toString(), pixelBitDepth, applicationCompositionType.toString())); + imageEssenceDescriptorID.toString(), pixelBitDepth, getApplicationCompositionType().toString())); } //FrameLayout @@ -231,7 +247,7 @@ private static void validateImageCharacteristics(CompositionImageEssenceDescript imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s has invalid FrameLayout(%s) as per %s", - imageEssenceDescriptorID.toString(), frameLayoutType.name(), applicationCompositionType.toString())); + imageEssenceDescriptorID.toString(), frameLayoutType.name(), getApplicationCompositionType().toString())); } else { //SampleRate Fraction sampleRate = imageEssenceDescriptorModel.getSampleRate(); @@ -239,7 +255,7 @@ private static void validateImageCharacteristics(CompositionImageEssenceDescript imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s has Invalid SampleRate(%s) for frame structure %s as per %s", - imageEssenceDescriptorID.toString(), sampleRate.toString(), frameLayoutType.name(), applicationCompositionType.toString())); + imageEssenceDescriptorID.toString(), sampleRate.toString(), frameLayoutType.name(), getApplicationCompositionType().toString())); } } @@ -249,7 +265,7 @@ private static void validateImageCharacteristics(CompositionImageEssenceDescript imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s has invalid combination of FrameLayOut(%s) for Sampling(%s) as per %s", - imageEssenceDescriptorID.toString(), frameLayoutType.name(), sampling.name(), applicationCompositionType.toString())); + imageEssenceDescriptorID.toString(), frameLayoutType.name(), sampling.name(), getApplicationCompositionType().toString())); } //Quantization @@ -262,7 +278,7 @@ private static void validateImageCharacteristics(CompositionImageEssenceDescript imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.APPLICATION_COMPOSITION_ERROR, IMFErrorLogger.IMFErrors.ErrorLevels.NON_FATAL, String.format("EssenceDescriptor with ID %s has invalid combination of quantization(%s)-Sampling(%s)-colorModel(%s)-color(%s) as per %s", - imageEssenceDescriptorID.toString(), quantization.name(), sampling.name(), colorModel.name(), color.name(), applicationCompositionType.toString())); + imageEssenceDescriptorID.toString(), quantization.name(), sampling.name(), colorModel.name(), color.name(), getApplicationCompositionType().toString())); } } From a030997596b6f505b8e16103a4532b043aec3359 Mon Sep 17 00:00:00 2001 From: Valentin NOEL Date: Wed, 12 Feb 2020 11:58:07 +0100 Subject: [PATCH 11/11] Revert App 2&2E compostion unit tests --- .../imflibrary/st2067_2/Application2CompositionTest.java | 6 +++--- .../st2067_2/Application2ExtendedCompositionTest.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/netflix/imflibrary/st2067_2/Application2CompositionTest.java b/src/test/java/com/netflix/imflibrary/st2067_2/Application2CompositionTest.java index 0187ed9e..db580f99 100644 --- a/src/test/java/com/netflix/imflibrary/st2067_2/Application2CompositionTest.java +++ b/src/test/java/com/netflix/imflibrary/st2067_2/Application2CompositionTest.java @@ -99,7 +99,7 @@ public void app2CompositionSubDescriptorsErrorTest() throws IOException { ("TestIMP/Application2/CPL_BLACKL_202_1080p_REC709_178_ENG_fe8cf2f4-1bcd-4145-8f72-6775af4038c4_SubDescriptorError.xml"); IMFErrorLogger imfErrorLogger = new IMFErrorLoggerImpl(); ApplicationCompositionFactory.getApplicationComposition(inputFile, imfErrorLogger); - Assert.assertEquals(imfErrorLogger.getErrors().size(), 0); + Assert.assertEquals(imfErrorLogger.getErrors().size(), 5); } @Test @@ -108,7 +108,7 @@ public void app2CompositionJPEG2000SubDescriptorMissingComponentDepthErrorTest() ("TestIMP/Application2/CPL_BLACKL_202_1080p_REC709_178_ENG_fe8cf2f4-1bcd-4145-8f72-6775af4038c4_SubDescriptorError_componentDepth_missing.xml"); IMFErrorLogger imfErrorLogger = new IMFErrorLoggerImpl(); ApplicationCompositionFactory.getApplicationComposition(inputFile, imfErrorLogger); - Assert.assertEquals(imfErrorLogger.getErrors().size(), 1); + Assert.assertEquals(imfErrorLogger.getErrors().size(), 6); } @Test @@ -117,7 +117,7 @@ public void app2CompositionJPEG2000SubDescriptorComponentDepthPixelDepthMismatch ("TestIMP/Application2/CPL_BLACKL_202_1080p_REC709_178_ENG_fe8cf2f4-1bcd-4145-8f72-6775af4038c4_SubDescriptorError_componentDepth_mismatch.xml"); IMFErrorLogger imfErrorLogger = new IMFErrorLoggerImpl(); ApplicationCompositionFactory.getApplicationComposition(inputFile, imfErrorLogger); - Assert.assertEquals(imfErrorLogger.getErrors().size(), 2); + Assert.assertEquals(imfErrorLogger.getErrors().size(), 5); } @Test diff --git a/src/test/java/com/netflix/imflibrary/st2067_2/Application2ExtendedCompositionTest.java b/src/test/java/com/netflix/imflibrary/st2067_2/Application2ExtendedCompositionTest.java index 782d659f..39b0c6d0 100644 --- a/src/test/java/com/netflix/imflibrary/st2067_2/Application2ExtendedCompositionTest.java +++ b/src/test/java/com/netflix/imflibrary/st2067_2/Application2ExtendedCompositionTest.java @@ -105,7 +105,7 @@ public void app2ExtendedCompositionSubDescriptorsErrorTest() throws IOException ("TestIMP/Application2Extended/CPL_BLACKL_202_1080p_REC709_178_ENG_fe8cf2f4-1bcd-4145-8f72-6775af4038c4_SubDescriptorError.xml"); IMFErrorLogger imfErrorLogger = new IMFErrorLoggerImpl(); ApplicationCompositionFactory.getApplicationComposition(inputFile, imfErrorLogger); - Assert.assertEquals(imfErrorLogger.getErrors().size(), 0); + Assert.assertEquals(imfErrorLogger.getErrors().size(), 4); } @Test