am 6be373de: am fc1bcc37: am 0278f2bf: am e8b7febd: Merge "media: use blocks number to find closest size" into mnc-dev

* commit '6be373dea441db670291d6019237f3daab105000':
  media: use blocks number to find closest size
This commit is contained in:
Ronghua Wu
2015-07-31 03:01:10 +00:00
committed by Android Git Automerger

View File

@@ -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;
}
}