summaryrefslogtreecommitdiffstats
path: root/services/camera/libcameraservice/api1
diff options
context:
space:
mode:
authorZhijun He <zhijunhe@google.com>2014-05-28 14:57:54 -0700
committerZhijun He <zhijunhe@google.com>2014-06-10 10:20:23 -0700
commit0cbfbf3624c67cf40a18d5405a46d002aa12a048 (patch)
tree3dc20024b634925744d71b0fe4b38a8ddb15d680 /services/camera/libcameraservice/api1
parentd8754e07e23eecb68068c0c392aeb0428c529e4e (diff)
downloadframeworks_av-0cbfbf3624c67cf40a18d5405a46d002aa12a048.zip
frameworks_av-0cbfbf3624c67cf40a18d5405a46d002aa12a048.tar.gz
frameworks_av-0cbfbf3624c67cf40a18d5405a46d002aa12a048.tar.bz2
Camera3: Separate the video and preview size filtering
Supported video sizes were generated from supported preview sizes, which effectively filtered out sizes larger than 1080p. This change filters the supported video sizes based on the media profiles supported h.264 max video frame width and height. Bug: 15287656 Change-Id: Ifbd9d37fb775371e2a4ee5cf80abbf83a75ffd65
Diffstat (limited to 'services/camera/libcameraservice/api1')
-rw-r--r--services/camera/libcameraservice/api1/client2/Parameters.cpp47
-rw-r--r--services/camera/libcameraservice/api1/client2/Parameters.h3
2 files changed, 36 insertions, 14 deletions
diff --git a/services/camera/libcameraservice/api1/client2/Parameters.cpp b/services/camera/libcameraservice/api1/client2/Parameters.cpp
index dece764..51b1980 100644
--- a/services/camera/libcameraservice/api1/client2/Parameters.cpp
+++ b/services/camera/libcameraservice/api1/client2/Parameters.cpp
@@ -29,6 +29,8 @@
#include "Parameters.h"
#include "system/camera.h"
+#include <media/MediaProfiles.h>
+#include <media/mediarecorder.h>
namespace android {
namespace camera2 {
@@ -59,7 +61,17 @@ status_t Parameters::initialize(const CameraMetadata *info) {
if (res != OK) return res;
const Size MAX_PREVIEW_SIZE = { MAX_PREVIEW_WIDTH, MAX_PREVIEW_HEIGHT };
- res = getFilteredPreviewSizes(MAX_PREVIEW_SIZE, &availablePreviewSizes);
+ // Treat the H.264 max size as the max supported video size.
+ MediaProfiles *videoEncoderProfiles = MediaProfiles::getInstance();
+ int32_t maxVideoWidth = videoEncoderProfiles->getVideoEncoderParamByName(
+ "enc.vid.width.max", VIDEO_ENCODER_H264);
+ int32_t maxVideoHeight = videoEncoderProfiles->getVideoEncoderParamByName(
+ "enc.vid.height.max", VIDEO_ENCODER_H264);
+ const Size MAX_VIDEO_SIZE = {maxVideoWidth, maxVideoHeight};
+
+ res = getFilteredSizes(MAX_PREVIEW_SIZE, &availablePreviewSizes);
+ if (res != OK) return res;
+ res = getFilteredSizes(MAX_VIDEO_SIZE, &availableVideoSizes);
if (res != OK) return res;
// TODO: Pick more intelligently
@@ -84,8 +96,17 @@ status_t Parameters::initialize(const CameraMetadata *info) {
ALOGV("Supported preview sizes are: %s", supportedPreviewSizes.string());
params.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES,
supportedPreviewSizes);
+
+ String8 supportedVideoSizes;
+ for (size_t i = 0; i < availableVideoSizes.size(); i++) {
+ if (i != 0) supportedVideoSizes += ",";
+ supportedVideoSizes += String8::format("%dx%d",
+ availableVideoSizes[i].width,
+ availableVideoSizes[i].height);
+ }
+ ALOGV("Supported video sizes are: %s", supportedVideoSizes.string());
params.set(CameraParameters::KEY_SUPPORTED_VIDEO_SIZES,
- supportedPreviewSizes);
+ supportedVideoSizes);
}
camera_metadata_ro_entry_t availableFpsRanges =
@@ -1660,13 +1681,13 @@ status_t Parameters::set(const String8& paramString) {
__FUNCTION__);
return BAD_VALUE;
}
- for (i = 0; i < availablePreviewSizes.size(); i++) {
- if ((availablePreviewSizes[i].width ==
+ for (i = 0; i < availableVideoSizes.size(); i++) {
+ if ((availableVideoSizes[i].width ==
validatedParams.videoWidth) &&
- (availablePreviewSizes[i].height ==
+ (availableVideoSizes[i].height ==
validatedParams.videoHeight)) break;
}
- if (i == availablePreviewSizes.size()) {
+ if (i == availableVideoSizes.size()) {
ALOGE("%s: Requested video size %d x %d is not supported",
__FUNCTION__, validatedParams.videoWidth,
validatedParams.videoHeight);
@@ -2497,7 +2518,7 @@ int Parameters::normalizedYToArray(int y) const {
return cropYToArray(normalizedYToCrop(y));
}
-status_t Parameters::getFilteredPreviewSizes(Size limit, Vector<Size> *sizes) {
+status_t Parameters::getFilteredSizes(Size limit, Vector<Size> *sizes) {
if (info == NULL) {
ALOGE("%s: Static metadata is not initialized", __FUNCTION__);
return NO_INIT;
@@ -2512,14 +2533,14 @@ status_t Parameters::getFilteredPreviewSizes(Size limit, Vector<Size> *sizes) {
staticInfo(ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES, SIZE_COUNT);
if (availableProcessedSizes.count < SIZE_COUNT) return BAD_VALUE;
- Size previewSize;
+ Size filteredSize;
for (size_t i = 0; i < availableProcessedSizes.count; i += SIZE_COUNT) {
- previewSize.width = availableProcessedSizes.data.i32[i];
- previewSize.height = availableProcessedSizes.data.i32[i+1];
+ filteredSize.width = availableProcessedSizes.data.i32[i];
+ filteredSize.height = availableProcessedSizes.data.i32[i+1];
// Need skip the preview sizes that are too large.
- if (previewSize.width <= limit.width &&
- previewSize.height <= limit.height) {
- sizes->push(previewSize);
+ if (filteredSize.width <= limit.width &&
+ filteredSize.height <= limit.height) {
+ sizes->push(filteredSize);
}
}
if (sizes->isEmpty()) {
diff --git a/services/camera/libcameraservice/api1/client2/Parameters.h b/services/camera/libcameraservice/api1/client2/Parameters.h
index 60c4687..28dd788 100644
--- a/services/camera/libcameraservice/api1/client2/Parameters.h
+++ b/services/camera/libcameraservice/api1/client2/Parameters.h
@@ -341,8 +341,9 @@ private:
int normalizedYToCrop(int y) const;
Vector<Size> availablePreviewSizes;
+ Vector<Size> availableVideoSizes;
// Get size list (that are no larger than limit) from static metadata.
- status_t getFilteredPreviewSizes(Size limit, Vector<Size> *sizes);
+ status_t getFilteredSizes(Size limit, Vector<Size> *sizes);
// Get max size (from the size array) that matches the given aspect ratio.
Size getMaxSizeForRatio(float ratio, const int32_t* sizeArray, size_t count);
};