mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Generalize findEsdsPosition to support other types
- This CL does not introduce functional changes. - This change will allow searching for the clli box while parsing the mdcv box in order to construct the HDR static info contained in ColorInfo. #minor-release PiperOrigin-RevId: 405656499
This commit is contained in:
parent
8545a8b35f
commit
383bad80ce
1 changed files with 16 additions and 6 deletions
|
|
@ -1435,7 +1435,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
||||||
int esdsAtomPosition =
|
int esdsAtomPosition =
|
||||||
childAtomType == Atom.TYPE_esds
|
childAtomType == Atom.TYPE_esds
|
||||||
? childPosition
|
? childPosition
|
||||||
: findEsdsPosition(parent, childPosition, childAtomSize);
|
: findBoxPosition(parent, Atom.TYPE_esds, childPosition, childAtomSize);
|
||||||
if (esdsAtomPosition != C.POSITION_UNSET) {
|
if (esdsAtomPosition != C.POSITION_UNSET) {
|
||||||
Pair<@NullableType String, byte @NullableType []> mimeTypeAndInitializationData =
|
Pair<@NullableType String, byte @NullableType []> mimeTypeAndInitializationData =
|
||||||
parseEsdsFromParent(parent, esdsAtomPosition);
|
parseEsdsFromParent(parent, esdsAtomPosition);
|
||||||
|
|
@ -1537,18 +1537,28 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the position of the esds box within a parent, or {@link C#POSITION_UNSET} if no esds
|
* Returns the position of the first box with the given {@code boxType} within {@code parent}, or
|
||||||
* box is found
|
* {@link C#POSITION_UNSET} if no such box is found.
|
||||||
|
*
|
||||||
|
* @param parent The {@link ParsableByteArray} to search. The search will start from the {@link
|
||||||
|
* ParsableByteArray#getPosition() current position}.
|
||||||
|
* @param boxType The box type to search for.
|
||||||
|
* @param parentBoxPosition The position in {@code parent} of the box we are searching.
|
||||||
|
* @param parentBoxSize The size of the parent box we are searching in bytes.
|
||||||
|
* @return The position of the first box with the given {@code boxType} within {@code parent}, or
|
||||||
|
* {@link C#POSITION_UNSET} if no such box is found.
|
||||||
*/
|
*/
|
||||||
private static int findEsdsPosition(ParsableByteArray parent, int position, int size)
|
private static int findBoxPosition(
|
||||||
|
ParsableByteArray parent, int boxType, int parentBoxPosition, int parentBoxSize)
|
||||||
throws ParserException {
|
throws ParserException {
|
||||||
int childAtomPosition = parent.getPosition();
|
int childAtomPosition = parent.getPosition();
|
||||||
while (childAtomPosition - position < size) {
|
ExtractorUtil.checkContainerInput(childAtomPosition >= parentBoxPosition, /* message= */ null);
|
||||||
|
while (childAtomPosition - parentBoxPosition < parentBoxSize) {
|
||||||
parent.setPosition(childAtomPosition);
|
parent.setPosition(childAtomPosition);
|
||||||
int childAtomSize = parent.readInt();
|
int childAtomSize = parent.readInt();
|
||||||
ExtractorUtil.checkContainerInput(childAtomSize > 0, "childAtomSize must be positive");
|
ExtractorUtil.checkContainerInput(childAtomSize > 0, "childAtomSize must be positive");
|
||||||
int childType = parent.readInt();
|
int childType = parent.readInt();
|
||||||
if (childType == Atom.TYPE_esds) {
|
if (childType == boxType) {
|
||||||
return childAtomPosition;
|
return childAtomPosition;
|
||||||
}
|
}
|
||||||
childAtomPosition += childAtomSize;
|
childAtomPosition += childAtomSize;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue