summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonghua Wu <ronghuawu@google.com>2015-07-31 02:40:28 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-07-31 02:40:28 +0000
commit0278f2bf2d627af718a7540f8c6aaa8a359caae6 (patch)
tree701ff6554de0c25f6948630bc86d436357434321
parent84ddee2e53f03f5a802191732670010e74375d59 (diff)
parente8b7febd62f899ed8920cbd484e18dea64b3a7ee (diff)
downloadframeworks_base-0278f2bf2d627af718a7540f8c6aaa8a359caae6.zip
frameworks_base-0278f2bf2d627af718a7540f8c6aaa8a359caae6.tar.gz
frameworks_base-0278f2bf2d627af718a7540f8c6aaa8a359caae6.tar.bz2
am e8b7febd: Merge "media: use blocks number to find closest size" into mnc-dev
* commit 'e8b7febd62f899ed8920cbd484e18dea64b3a7ee': media: use blocks number to find closest size
-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;
}
}