mirror of
https://github.com/samsonjs/media.git
synced 2026-04-07 11:35:46 +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 =
|
||||
childAtomType == Atom.TYPE_esds
|
||||
? childPosition
|
||||
: findEsdsPosition(parent, childPosition, childAtomSize);
|
||||
: findBoxPosition(parent, Atom.TYPE_esds, childPosition, childAtomSize);
|
||||
if (esdsAtomPosition != C.POSITION_UNSET) {
|
||||
Pair<@NullableType String, byte @NullableType []> mimeTypeAndInitializationData =
|
||||
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
|
||||
* box is found
|
||||
* Returns 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.
|
||||
*
|
||||
* @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 {
|
||||
int childAtomPosition = parent.getPosition();
|
||||
while (childAtomPosition - position < size) {
|
||||
ExtractorUtil.checkContainerInput(childAtomPosition >= parentBoxPosition, /* message= */ null);
|
||||
while (childAtomPosition - parentBoxPosition < parentBoxSize) {
|
||||
parent.setPosition(childAtomPosition);
|
||||
int childAtomSize = parent.readInt();
|
||||
ExtractorUtil.checkContainerInput(childAtomSize > 0, "childAtomSize must be positive");
|
||||
int childType = parent.readInt();
|
||||
if (childType == Atom.TYPE_esds) {
|
||||
if (childType == boxType) {
|
||||
return childAtomPosition;
|
||||
}
|
||||
childAtomPosition += childAtomSize;
|
||||
|
|
|
|||
Loading…
Reference in a new issue