summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorRonghua Wu <ronghuawu@google.com>2015-07-30 10:54:47 -0700
committerRonghua Wu <ronghuawu@google.com>2015-07-30 13:01:20 -0700
commite595268e98ee609899c71c4114fc098daa2ee1f4 (patch)
tree0948783468785cec5d37425ea555b0b99e911f0c /media
parent74a0744ec19de54096638978bfe1eccfe2ed4e01 (diff)
downloadframeworks_base-e595268e98ee609899c71c4114fc098daa2ee1f4.zip
frameworks_base-e595268e98ee609899c71c4114fc098daa2ee1f4.tar.gz
frameworks_base-e595268e98ee609899c71c4114fc098daa2ee1f4.tar.bz2
media: use blocks number to find closest size
Bug: 22504214 Change-Id: I056e19ac5fdbdff2c5d297b600210c07ae5ed4f4
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/MediaCodecInfo.java15
1 files changed, 10 insertions, 5 deletions
diff --git a/media/java/android/media/MediaCodecInfo.java b/media/java/android/media/MediaCodecInfo.java
index 65d0450..8243d40 100644
--- a/media/java/android/media/MediaCodecInfo.java
+++ b/media/java/android/media/MediaCodecInfo.java
@@ -1198,15 +1198,20 @@ public final class MediaCodecInfo {
(double) mFrameRateRange.getUpper()));
}
+ private int getBlockCount(int width, int height) {
+ return Utils.divUp(width, mBlockWidth) * Utils.divUp(height, mBlockHeight);
+ }
+
@NonNull
private Size findClosestSize(int width, int height) {
- int targetPixels = width * height;
+ int targetBlockCount = getBlockCount(width, height);
Size closestSize = null;
- int mimPixelsDiff = Integer.MAX_VALUE;
+ int minDiff = Integer.MAX_VALUE;
for (Size size : mMeasuredFrameRates.keySet()) {
- int pixelsDiff = Math.abs(targetPixels - size.getWidth() * size.getHeight());
- if (pixelsDiff < mimPixelsDiff) {
- mimPixelsDiff = pixelsDiff;
+ int diff = Math.abs(targetBlockCount -
+ getBlockCount(size.getWidth(), size.getHeight()));
+ if (diff < minDiff) {
+ minDiff = diff;
closestSize = size;
}
}