Skip to content
Open
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: 4 additions & 3 deletions src/main/java/tv/amwa/maj/io/mxf/MXFBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,11 @@ public final static synchronized void registerMXF() {
Warehouse.lookForClass(PrimerPackImpl.class);
Warehouse.lookForClass(RandomIndexPackImpl.class);
Warehouse.lookForClass(IndexTableSegmentImpl.class);
Warehouse.registerTypes(TypeDefinitions.class, MXFConstants.RP210_NAMESPACE, MXFConstants.RP210_PREFIX);


TypeDefinitionRecordImpl.registerInterfaceMapping(DeltaEntry.class, DeltaEntryImpl.class);
TypeDefinitionRecordImpl.registerInterfaceMapping(IndexEntry.class, IndexEntryImpl.class);

Warehouse.registerTypes(TypeDefinitions.class, MXFConstants.RP210_NAMESPACE, MXFConstants.RP210_PREFIX);

mxfRegistration = true;
}
Expand Down Expand Up @@ -745,7 +746,7 @@ private final static long writeToLocalSet(
throws NullPointerException {

if (toWrite == null)
throw new NullPointerException("Cannot calculat the length as a local set value for a null metadata object.");
throw new NullPointerException("Cannot calculate the length as a local set value for a null metadata object.");

ClassDefinition classOfMetadata = MediaEngine.getClassDefinition(toWrite);
SortedMap<? extends PropertyDefinition,? extends PropertyValue> properties = classOfMetadata.getProperties(toWrite);
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/tv/amwa/maj/io/mxf/impl/IndexEntryImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.w3c.dom.Node;

import tv.amwa.maj.exception.EndOfDataException;
import tv.amwa.maj.exception.InsufficientSpaceException;
import tv.amwa.maj.exception.PropertyNotPresentException;
import tv.amwa.maj.integer.Int8;
import tv.amwa.maj.integer.UInt32Array;
Expand Down Expand Up @@ -401,5 +402,43 @@ public final static IndexEntry createFromBuffer(

return new IndexEntryImpl(temporalOffset, keyFrameOffset, flags, streamOffset, unresolvedBytes);
}

public final static void writeToBuffer(
IndexEntry entry,
ByteBuffer buffer)
throws NullPointerException,
InsufficientSpaceException {

if (entry == null)
throw new NullPointerException("Cannot write a null index entry to a buffer.");
if (buffer == null)
throw new NullPointerException("Cannot write an index entry to a null buffer.");

if (buffer.remaining() < lengthAsBuffer(entry))
throw new InsufficientSpaceException("Insufficient space in the given buffer to write an index entry value.");

buffer.put(entry.getTemporalOffset());
buffer.put(entry.getKeyFrameOffset());
buffer.put(entry.getFlags());
buffer.putLong(entry.getStreamOffset());
for (int offset : entry.getSliceOffset()) {
buffer.putInt(offset);
}
for (Rational pos : entry.getPosTable()) {
buffer.putInt(pos.getNumerator());
buffer.putInt(pos.getDenominator());
}

}

public final static long lengthAsBuffer(
IndexEntry value) {

long length = 11l;
length += 4*value.getSliceOffset().length;
length += 8*value.getPosTable().length;

return length;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,11 @@ public void setDeltaEntries(
optional = true,
uniqueIdentifier = false,
pid = 0x3f0a,
symbol = "IndexEntryArray")
symbol = "IndexEntryArray",
// Make this come last in the local set, since it depends on sliceCount and posTableCount values
// As per the MXF spec this ordering should not be needed, but if we don't do this
// Adobe PremierPro 2022 can't import the files - Adobe pls fix your product!
weight = 2147483647)
public IndexEntry[] getIndexEntryArray()
throws PropertyNotPresentException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,7 @@ public static RandomIndexPack createFromBytes(
ByteBuffer ripBytes)
throws BufferUnderflowException {

UL ripKey = MXFBuilder.readKey(ripBytes);
if (ripKey == null)
return null;
if (!ripKeyValue.equals(ripKey))
return null;

long ripLength = MXFBuilder.readBERLength(ripBytes);
long ripLength = ripBytes.array().length;
int ripItemCount = (int) (ripLength - 4) / 12;
// If remainder, the random index pack is corrupt in some way.
if (((ripLength - 4) % 12) != 0) return null;
Expand Down