mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
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
This commit is contained in:
parent
ad5f2387e0
commit
12ce9f7c0f
1 changed files with 4 additions and 2 deletions
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package androidx.media3.transformer;
|
package androidx.media3.transformer;
|
||||||
|
|
||||||
|
import static java.lang.Math.max;
|
||||||
import static java.lang.Math.round;
|
import static java.lang.Math.round;
|
||||||
|
|
||||||
import android.media.MediaCodec;
|
import android.media.MediaCodec;
|
||||||
|
|
@ -127,12 +128,13 @@ public final class EncoderUtil {
|
||||||
MediaCodecInfo.CodecProfileLevel[] profileLevels =
|
MediaCodecInfo.CodecProfileLevel[] profileLevels =
|
||||||
encoderInfo.getCapabilitiesForType(mimeType).profileLevels;
|
encoderInfo.getCapabilitiesForType(mimeType).profileLevels;
|
||||||
|
|
||||||
|
int maxSupportedLevel = LEVEL_UNSET;
|
||||||
for (MediaCodecInfo.CodecProfileLevel profileLevel : profileLevels) {
|
for (MediaCodecInfo.CodecProfileLevel profileLevel : profileLevels) {
|
||||||
if (profileLevel.profile == profile) {
|
if (profileLevel.profile == profile) {
|
||||||
return profileLevel.level;
|
maxSupportedLevel = max(maxSupportedLevel, profileLevel.level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return LEVEL_UNSET;
|
return maxSupportedLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue