Commit 12ce9f7c by claincly Committed by Ian Baker

Fix the logic to get the max supported encoding level.

On some Android devices, the return value of

```
MediaCodecInfo.getCapabilitiesForType(mimeType).profileLevels
```

contains one entry for each encoding profile, like <profile, maxSupportedLevel>

but on some other devices, there are multiple entries for the same profile,

like <HIGH_PROFILE, LEVEL1>, <HIGH_PROFILE, LEVEL2>, <HIGH_PROFILE, LEVEL3>,
where we need to iterate through all the entries and find the max.

PiperOrigin-RevId: 427727030
parent ad5f2387
......@@ -16,6 +16,7 @@
package androidx.media3.transformer;
import static java.lang.Math.max;
import static java.lang.Math.round;
import android.media.MediaCodec;
......@@ -127,12 +128,13 @@ public final class EncoderUtil {
MediaCodecInfo.CodecProfileLevel[] profileLevels =
encoderInfo.getCapabilitiesForType(mimeType).profileLevels;
int maxSupportedLevel = LEVEL_UNSET;
for (MediaCodecInfo.CodecProfileLevel profileLevel : profileLevels) {
if (profileLevel.profile == profile) {
return profileLevel.level;
maxSupportedLevel = max(maxSupportedLevel, profileLevel.level);
}
}
return LEVEL_UNSET;
return maxSupportedLevel;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment