Add resolution fallback for 25% of requested.
If a device only supports 1920x1080 as maximum resolution, then adding the 25% case ensures 8k is reduced correctly. PiperOrigin-RevId: 502588364
This commit is contained in:
parent
d092b5261e
commit
a3b0708d31
@ -241,7 +241,7 @@ public final class EncoderUtil {
|
|||||||
|
|
||||||
float[] reductionFactors =
|
float[] reductionFactors =
|
||||||
new float[] {
|
new float[] {
|
||||||
0.95f, 0.9f, 0.85f, 0.8f, 0.75f, 0.7f, 2f / 3f, 0.6f, 0.55f, 0.5f, 0.4f, 1f / 3f
|
0.95f, 0.9f, 0.85f, 0.8f, 0.75f, 0.7f, 2f / 3f, 0.6f, 0.55f, 0.5f, 0.4f, 1f / 3f, 0.25f
|
||||||
};
|
};
|
||||||
for (float reductionFactor : reductionFactors) {
|
for (float reductionFactor : reductionFactors) {
|
||||||
newWidth = alignResolution(round(width * reductionFactor), widthAlignment);
|
newWidth = alignResolution(round(width * reductionFactor), widthAlignment);
|
||||||
|
@ -149,6 +149,20 @@ public class EncoderUtilTest {
|
|||||||
assertThat(closestSupportedResolution.getHeight()).isEqualTo(1920);
|
assertThat(closestSupportedResolution.getHeight()).isEqualTo(1920);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSupportedResolution_findsOneQuarterOfTheOriginalSize() {
|
||||||
|
ImmutableList<MediaCodecInfo> supportedEncoders = EncoderUtil.getSupportedEncoders(MIME_TYPE);
|
||||||
|
MediaCodecInfo encoderInfo = supportedEncoders.get(0);
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
Size closestSupportedResolution =
|
||||||
|
EncoderUtil.getSupportedResolution(encoderInfo, MIME_TYPE, 7680, 4320);
|
||||||
|
|
||||||
|
assertThat(closestSupportedResolution).isNotNull();
|
||||||
|
assertThat(closestSupportedResolution.getWidth()).isEqualTo(1920);
|
||||||
|
assertThat(closestSupportedResolution.getHeight()).isEqualTo(1080);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see EncoderUtil#getSupportedEncoderNamesForHdrEditing(String, ColorInfo)
|
* @see EncoderUtil#getSupportedEncoderNamesForHdrEditing(String, ColorInfo)
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user