liyujie
2025-08-28 786ff4f4ca2374bdd9177f2e24b503d43e7a3b93
android/packages/apps/Camera2/src/com/android/camera/settings/ResolutionUtil.java
old mode 100755new mode 100644
....@@ -359,6 +359,16 @@
359359 return Math.abs(ar1.toDouble() - ar2.toDouble()) < ASPECT_RATIO_TOLERANCE;
360360 }
361361
362
+ public static boolean is16BitAligned(Size size) {
363
+ int width = size.getWidth();
364
+ int height = size.getHeight();
365
+ if (((width & 15) == 0) && ((height & 15) == 0)) {
366
+ return true;
367
+ } else {
368
+ return false;
369
+ }
370
+ }
371
+
362372 /**
363373 * Selects the maximal resolution for the given desired aspect ratio from all available
364374 * resolutions. If no resolution exists for the desired aspect ratio, return a resolution
....@@ -392,9 +402,11 @@
392402 for (Size size : sizes) {
393403 Rational aspectRatio = getAspectRatio(size);
394404 // Skip if the aspect ratio is not desired.
395
- if (!hasSameAspectRatio(aspectRatio, desiredAspectRatio)) {
405
+ if (!hasSameAspectRatio(aspectRatio, desiredAspectRatio) ||
406
+ !is16BitAligned(size)) {
396407 continue;
397408 }
409
+
398410 int pixelNum = size.getWidth() * size.getHeight();
399411 if (pixelNum > maxPixelNumWithAspect) {
400412 maxPixelNumWithAspect = pixelNum;