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:
samrobinson 2023-01-17 16:07:39 +00:00 committed by christosts
parent d092b5261e
commit a3b0708d31
2 changed files with 15 additions and 1 deletions

View File

@ -241,7 +241,7 @@ public final class EncoderUtil {
float[] reductionFactors =
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) {
newWidth = alignResolution(round(width * reductionFactor), widthAlignment);

View File

@ -149,6 +149,20 @@ public class EncoderUtilTest {
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)
*/