aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsafarend <s.a.f.a.r.end@live.com.au>2015-08-31 21:38:45 +1200
committersafarend <s.a.f.a.r.end@live.com.au>2015-08-31 21:38:45 +1200
commit92291b7d62486019a96d063ce9cd8715f1c0a8a9 (patch)
tree1ff0cf35ba1521744984ef7162d4c558bb52279a
parentc93ec39f5d06ef40631eceab147a121dbaf80815 (diff)
Improve Camera Quality
Change-Id: I2cf4f217d33f6100e16a3e3715dd52da4a9a2366
-rw-r--r--camera/CameraWrapper.cpp88
-rw-r--r--configs/media_profiles.xml198
-rw-r--r--include/camera/CameraParametersExtra.h28
-rw-r--r--include/camera/CameraParametersExtraDurationTimer.h2
4 files changed, 236 insertions, 80 deletions
diff --git a/camera/CameraWrapper.cpp b/camera/CameraWrapper.cpp
index f593fcf..3d56b4c 100644
--- a/camera/CameraWrapper.cpp
+++ b/camera/CameraWrapper.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014, The CyanogenMod Project
+ * Copyright (C) 2015, The CyanogenMod Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,11 +22,10 @@
*/
//#define LOG_NDEBUG 0
+//#define LOG_PARAMETERS
-#define LOG_TAG "CameraWrapper"
+#define LOG_TAG "camera"
#include <cutils/log.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <utils/threads.h>
#include <utils/String8.h>
@@ -35,15 +34,14 @@
#include <camera/Camera.h>
#include <camera/CameraParameters.h>
-#define CAMID_PATH "/data/CameraID.txt"
-
static android::Mutex gCameraWrapperLock;
static camera_module_t *gVendorModule = 0;
static char **fixed_set_params = NULL;
static int camera_device_open(const hw_module_t *module, const char *name,
- hw_device_t **device);
+ hw_device_t **device);
+static int camera_device_close(hw_device_t *device);
static int camera_get_number_of_cameras(void);
static int camera_get_camera_info(int camera_id, struct camera_info *info);
@@ -53,7 +51,7 @@ static struct hw_module_methods_t camera_module_methods = {
camera_module_t HAL_MODULE_INFO_SYM = {
.common = {
- tag: HARDWARE_MODULE_TAG,
+ .tag = HARDWARE_MODULE_TAG,
.module_api_version = CAMERA_MODULE_API_VERSION_1_0,
.hal_api_version = HARDWARE_HAL_API_VERSION,
.id = CAMERA_HARDWARE_MODULE_ID,
@@ -83,36 +81,6 @@ typedef struct wrapper_camera_device {
})
#define CAMERA_ID(device) (((wrapper_camera_device_t *)(device))->id)
-static void fix_camera_id_permissions()
-{
- FILE* camidfile;
- int amode;
- int ret = -1;
- camidfile = fopen(CAMID_PATH, "w");
- if (camidfile == 0) {
- fprintf(stderr, "open(%s) failed\n", CAMID_PATH);
- ALOGE("Can't open %s\n", CAMID_PATH);
- } else {
- ALOGD("Setting permissions of %s\n", CAMID_PATH);
-
- /* write permissions for the file owner */
- amode = S_IWUSR;
- ret = chmod(CAMID_PATH, amode);
-
- /* owner: media; group: system */
- char* chown_cmd = (char*) malloc(strlen("chown media ") + strlen(CAMID_PATH) + 1);
- char* chgrp_cmd = (char*) malloc(strlen("chgrp system ") + strlen(CAMID_PATH) + 1);
- sprintf(chown_cmd, "chown media %s", CAMID_PATH);
- sprintf(chgrp_cmd, "chgrp system %s", CAMID_PATH);
- system(chown_cmd);
- system(chgrp_cmd);
-
- if (ret != 0) {
- fprintf(stderr, "chmod() on file %s failed\n", CAMID_PATH);
- ALOGE("Can't set permissions on %s\n", CAMID_PATH);
- }
- }
-}
static int check_vendor_module()
{
@@ -123,19 +91,21 @@ static int check_vendor_module()
return 0;
rv = hw_get_module_by_class("camera", "vendor",
- (const hw_module_t**)&gVendorModule);
+ (const hw_module_t **)&gVendorModule);
+
if (rv)
ALOGE("failed to open vendor camera module");
return rv;
}
-static char *camera_fixup_getparams(int id, const char *settings)
+static char *camera_fixup_getparams(int __attribute__((unused)) id,
+ const char *settings)
{
android::CameraParameters params;
params.unflatten(android::String8(settings));
-#if !LOG_NDEBUG
- ALOGV("%s: original parameters:", __FUNCTION__);
+#ifdef LOG_PARAMETERS
+ ALOGV("%s: Original parameters:", __FUNCTION__);
params.dump();
#endif
@@ -150,14 +120,14 @@ static char *camera_fixup_getparams(int id, const char *settings)
params.set("max-sharpness", params.get("sharpness-max"));
}
-#if !LOG_NDEBUG
+ android::String8 strParams = params.flatten();
+ char *ret = strdup(strParams.string());
+
+#ifdef LOG_PARAMETERS
ALOGV("%s: fixed parameters:", __FUNCTION__);
params.dump();
#endif
- android::String8 strParams = params.flatten();
- char *ret = strdup(strParams.string());
-
return ret;
}
@@ -166,7 +136,7 @@ static char *camera_fixup_setparams(int id, const char *settings)
android::CameraParameters params;
params.unflatten(android::String8(settings));
-#if !LOG_NDEBUG
+#ifdef LOG_PARAMETERS
ALOGV("%s: original parameters:", __FUNCTION__);
params.dump();
#endif
@@ -182,24 +152,27 @@ static char *camera_fixup_setparams(int id, const char *settings)
params.set("sharpness-max", params.get("max-sharpness"));
}
-#if !LOG_NDEBUG
- ALOGV("%s: fixed parameters:", __FUNCTION__);
- params.dump();
-#endif
android::String8 strParams = params.flatten();
+
if (fixed_set_params[id])
free(fixed_set_params[id]);
fixed_set_params[id] = strdup(strParams.string());
char *ret = fixed_set_params[id];
+#ifdef LOG_PARAMETERS
+ ALOGV("%s: fixed parameters:", __FUNCTION__);
+ params.dump();
+#endif
+
return ret;
}
/*******************************************************************
* implementation of camera_device_ops functions
*******************************************************************/
-
+static char *camera_get_parameters(struct camera_device *device);
+static int camera_set_parameters(struct camera_device *device, const char *params);
static int camera_set_preview_window(struct camera_device *device,
struct preview_stream_ops *window)
{
@@ -225,8 +198,7 @@ static void camera_set_callbacks(struct camera_device *device,
if (!device)
return;
- VENDOR_CALL(device, set_callbacks, notify_cb, data_cb, data_cb_timestamp,
- get_memory, user);
+ VENDOR_CALL(device, set_callbacks, notify_cb, data_cb, data_cb_timestamp, get_memory, user);
}
static void camera_enable_msg_type(struct camera_device *device,
@@ -363,7 +335,6 @@ static int camera_auto_focus(struct camera_device *device)
if (!device)
return -EINVAL;
-
return VENDOR_CALL(device, auto_focus);
}
@@ -400,8 +371,7 @@ static int camera_cancel_picture(struct camera_device *device)
return VENDOR_CALL(device, cancel_picture);
}
-static int camera_set_parameters(struct camera_device *device,
- const char *params)
+static int camera_set_parameters(struct camera_device *device, const char *params)
{
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
@@ -531,7 +501,7 @@ static int camera_device_open(const hw_module_t *module, const char *name,
android::Mutex::Autolock lock(gCameraWrapperLock);
- ALOGV("%s", __FUNCTION__);
+ ALOGV("camera_device open");
if (name != NULL) {
if (check_vendor_module())
@@ -646,4 +616,4 @@ static int camera_get_camera_info(int camera_id, struct camera_info *info)
if (check_vendor_module())
return 0;
return gVendorModule->get_camera_info(camera_id, info);
-}
+} \ No newline at end of file
diff --git a/configs/media_profiles.xml b/configs/media_profiles.xml
index 2917dfa..4ca2373 100644
--- a/configs/media_profiles.xml
+++ b/configs/media_profiles.xml
@@ -38,7 +38,7 @@
<!ATTLIST Audio sampleRate CDATA #REQUIRED>
<!ATTLIST Audio channels (1|2) #REQUIRED>
<!ELEMENT ImageEncoding EMPTY>
-<!ATTLIST ImageEncoding quality (90|80|70|60|50|40) #REQUIRED>
+<!ATTLIST ImageEncoding quality (100|100|100|100|100|100) #REQUIRED>
<!ELEMENT ImageDecoding EMPTY>
<!ATTLIST ImageDecoding memCap CDATA #REQUIRED>
<!ELEMENT Camera EMPTY>
@@ -79,7 +79,18 @@
<MediaSettings>
<!-- Each camcorder profile defines a set of predefined configuration parameters -->
<CamcorderProfiles cameraId="0" startOffsetMs="700">
+ <EncoderProfile quality="low" fileFormat="mp4" duration="30">
+ <Video codec="h264"
+ bitRate="384000"
+ width="176"
+ height="144"
+ frameRate="30" />
+ <Audio codec="aac"
+ bitRate="128000"
+ sampleRate="48000"
+ channels="2" />
+ </EncoderProfile>
<EncoderProfile quality="high" fileFormat="mp4" duration="30">
<Video codec="h264"
@@ -94,8 +105,21 @@
channels="2" />
</EncoderProfile>
+ <EncoderProfile quality="qcif" fileFormat="mp4" duration="30">
+ <Video codec="h264"
+ bitRate="384000"
+ width="176"
+ height="144"
+ frameRate="30" />
+
+ <Audio codec="aac"
+ bitRate="128000"
+ sampleRate="48000"
+ channels="2" />
+ </EncoderProfile>
+
<EncoderProfile quality="qvga" fileFormat="mp4" duration="30">
- <Video codec="h264"
+ <Video codec="h264"
bitRate="767000"
width="320"
height="240"
@@ -107,6 +131,19 @@
channels="2" />
</EncoderProfile>
+ <EncoderProfile quality="480p" fileFormat="mp4" duration="30">
+ <Video codec="h264"
+ bitRate="3449000"
+ width="720"
+ height="480"
+ frameRate="30" />
+
+ <Audio codec="aac"
+ bitRate="256000"
+ sampleRate="48000"
+ channels="2" />
+ </EncoderProfile>
+
<EncoderProfile quality="720p" fileFormat="mp4" duration="30">
<Video codec="h264"
bitRate="12000000"
@@ -121,7 +158,7 @@
</EncoderProfile>
<EncoderProfile quality="1080p" fileFormat="mp4" duration="30">
- <Video codec="h264"
+ <Video codec="h264"
bitRate="17000000"
width="1920"
height="1080"
@@ -133,9 +170,25 @@
channels="2" />
</EncoderProfile>
+ <EncoderProfile quality="timelapselow" fileFormat="mp4" duration="30">
+ <Video codec="h264"
+ bitRate="384000"
+ width="176"
+ height="144"
+ frameRate="30" />
+
+ <!--
+ The Audio part of the profile will not be used since time lapse mode
+ does not capture audio
+ -->
+ <Audio codec="aac"
+ bitRate="128000"
+ sampleRate="48000"
+ channels="2" />
+ </EncoderProfile>
<EncoderProfile quality="timelapsehigh" fileFormat="mp4" duration="30">
- <Video codec="h264"
+ <Video codec="h264"
bitRate="17000000"
width="1920"
height="1080"
@@ -151,6 +204,22 @@
channels="2" />
</EncoderProfile>
+ <EncoderProfile quality="timelapseqcif" fileFormat="mp4" duration="30">
+ <Video codec="h264"
+ bitRate="384000"
+ width="176"
+ height="144"
+ frameRate="30" />
+
+ <!--
+ The Audio part of the profile will not be used since time lapse mode
+ does not capture audio
+ -->
+ <Audio codec="aac"
+ bitRate="128000"
+ sampleRate="48000"
+ channels="2" />
+ </EncoderProfile>
<EncoderProfile quality="timelapseqvga" fileFormat="mp4" duration="30">
<Video codec="h264"
@@ -169,6 +238,23 @@
channels="2" />
</EncoderProfile>
+ <EncoderProfile quality="timelapse480p" fileFormat="mp4" duration="30">
+ <Video codec="h264"
+ bitRate="3449000"
+ width="720"
+ height="480"
+ frameRate="30" />
+
+ <!--
+ The Audio part of the profile will not be used since time lapse mode
+ does not capture audio
+ -->
+ <Audio codec="aac"
+ bitRate="256000"
+ sampleRate="48000"
+ channels="2" />
+ </EncoderProfile>
+
<EncoderProfile quality="timelapse720p" fileFormat="mp4" duration="30">
<Video codec="h264"
bitRate="12000000"
@@ -203,16 +289,28 @@
channels="2" />
</EncoderProfile>
- <ImageEncoding quality="90" />
- <ImageEncoding quality="80" />
- <ImageEncoding quality="70" />
- <ImageDecoding memCap="20000000" />
+ <ImageEncoding quality="100" />
+ <ImageEncoding quality="100" />
+ <ImageEncoding quality="100" />
+ <ImageDecoding memCap="50000000" />
- </CamcorderProfiles>
+ </CamcorderProfiles>
<!-- Front Camera -->
<CamcorderProfiles cameraId="1" startOffsetMs="700">
+ <EncoderProfile quality="low" fileFormat="mp4" duration="30">
+ <Video codec="h264"
+ bitRate="384000"
+ width="176"
+ height="144"
+ frameRate="30" />
+
+ <Audio codec="aac"
+ bitRate="128000"
+ sampleRate="48000"
+ channels="2" />
+ </EncoderProfile>
<EncoderProfile quality="high" fileFormat="mp4" duration="30">
<Video codec="h264"
@@ -227,6 +325,18 @@
channels="2" />
</EncoderProfile>
+ <EncoderProfile quality="qcif" fileFormat="mp4" duration="30">
+ <Video codec="h264"
+ bitRate="384000"
+ width="176"
+ height="144"
+ frameRate="30" />
+
+ <Audio codec="aac"
+ bitRate="128000"
+ sampleRate="48000"
+ channels="2" />
+ </EncoderProfile>
<EncoderProfile quality="qvga" fileFormat="mp4" duration="30">
<Video codec="h264"
@@ -241,6 +351,19 @@
channels="2" />
</EncoderProfile>
+ <EncoderProfile quality="480p" fileFormat="mp4" duration="30">
+ <Video codec="h264"
+ bitRate="3449000"
+ width="720"
+ height="480"
+ frameRate="30" />
+
+ <Audio codec="aac"
+ bitRate="256000"
+ sampleRate="48000"
+ channels="2" />
+ </EncoderProfile>
+
<EncoderProfile quality="720p" fileFormat="mp4" duration="30">
<Video codec="h264"
bitRate="12000000"
@@ -267,6 +390,22 @@
channels="2" />
</EncoderProfile>
+ <EncoderProfile quality="timelapselow" fileFormat="mp4" duration="30">
+ <Video codec="h264"
+ bitRate="384000"
+ width="176"
+ height="144"
+ frameRate="30" />
+
+ <!--
+ The Audio part of the profile will not be used since time lapse mode
+ does not capture audio
+ -->
+ <Audio codec="aac"
+ bitRate="128000"
+ sampleRate="48000"
+ channels="2" />
+ </EncoderProfile>
<EncoderProfile quality="timelapsehigh" fileFormat="mp4" duration="30">
<Video codec="h264"
@@ -285,6 +424,22 @@
channels="2" />
</EncoderProfile>
+ <EncoderProfile quality="timelapseqcif" fileFormat="mp4" duration="30">
+ <Video codec="h264"
+ bitRate="384000"
+ width="176"
+ height="144"
+ frameRate="30" />
+
+ <!--
+ The Audio part of the profile will not be used since time lapse mode
+ does not capture audio
+ -->
+ <Audio codec="aac"
+ bitRate="128000"
+ sampleRate="48000"
+ channels="2" />
+ </EncoderProfile>
<EncoderProfile quality="timelapseqvga" fileFormat="mp4" duration="30">
<Video codec="h264"
@@ -303,6 +458,23 @@
channels="2" />
</EncoderProfile>
+ <EncoderProfile quality="timelapse480p" fileFormat="mp4" duration="30">
+ <Video codec="h264"
+ bitRate="3449000"
+ width="720"
+ height="480"
+ frameRate="30" />
+
+ <!--
+ The Audio part of the profile will not be used since time lapse mode
+ does not capture audio
+ -->
+ <Audio codec="aac"
+ bitRate="256000"
+ sampleRate="48000"
+ channels="2" />
+ </EncoderProfile>
+
<EncoderProfile quality="timelapse720p" fileFormat="mp4" duration="30">
<Video codec="h264"
bitRate="12000000"
@@ -337,10 +509,10 @@
channels="2" />
</EncoderProfile>
- <ImageEncoding quality="90" />
- <ImageEncoding quality="80" />
- <ImageEncoding quality="70" />
- <ImageDecoding memCap="20000000" />
+ <ImageEncoding quality="100" />
+ <ImageEncoding quality="100" />
+ <ImageEncoding quality="100" />
+ <ImageDecoding memCap="50000000" />
</CamcorderProfiles>
diff --git a/include/camera/CameraParametersExtra.h b/include/camera/CameraParametersExtra.h
index 87030bc..b46bb23 100644
--- a/include/camera/CameraParametersExtra.h
+++ b/include/camera/CameraParametersExtra.h
@@ -20,10 +20,17 @@
const char CameraParameters::KEY_CITYID[] = "cityid"; \
const char CameraParameters::KEY_WEATHER[] = "weather"; \
const char CameraParameters::ISO_AUTO[] = "auto"; \
-const char CameraParameters::ISO_100[] = "100"; \
-const char CameraParameters::ISO_200[] = "200"; \
-const char CameraParameters::ISO_400[] = "400"; \
+const char CameraParameters::ISO_NIGHT[] = "night"; \
+const char CameraParameters::ISO_SPORTS[] = "sports"; \
+const char CameraParameters::ISO_6400[] = "6400"; \
+const char CameraParameters::ISO_3200[] = "3200"; \
+const char CameraParameters::ISO_1600[] = "1600"; \
const char CameraParameters::ISO_800[] = "800"; \
+const char CameraParameters::ISO_400[] = "400"; \
+const char CameraParameters::ISO_200[] = "200"; \
+const char CameraParameters::ISO_100[] = "100"; \
+const char CameraParameters::ISO_80[] = "80"; \
+const char CameraParameters::ISO_50[] = "50"; \
\
int CameraParameters::getInt64(const char *key) const { return -1; } \
extern "C" { \
@@ -40,13 +47,20 @@ CAMERA_PARAMETERS_EXTRA_C_DURATION_TIMER \
static const char KEY_CITYID[]; \
static const char KEY_WEATHER[]; \
static const char ISO_AUTO[]; \
- static const char ISO_100[]; \
- static const char ISO_200[]; \
- static const char ISO_400[]; \
+ static const char ISO_NIGHT[]; \
+ static const char ISO_SPORTS[]; \
+ static const char ISO_6400[]; \
+ static const char ISO_3200[]; \
+ static const char ISO_1600[]; \
static const char ISO_800[]; \
+ static const char ISO_400[]; \
+ static const char ISO_200[]; \
+ static const char ISO_100[]; \
+ static const char ISO_80[]; \
+ static const char ISO_50[]; \
\
int getInt64(const char *key) const; \
\
/* LAST_LINE OF CAMERA_PARAMETERS_EXTRA_H, every line before this one *MUST* have
* a backslash \ at the end of the line or else everything will break.
- */
+ */ \ No newline at end of file
diff --git a/include/camera/CameraParametersExtraDurationTimer.h b/include/camera/CameraParametersExtraDurationTimer.h
index 9f2f049..daf7e15 100644
--- a/include/camera/CameraParametersExtraDurationTimer.h
+++ b/include/camera/CameraParametersExtraDurationTimer.h
@@ -59,4 +59,4 @@ long long DurationTimer::durationUsecs(void) const \
} \
ptv->tv_sec += usec / 1000000; \
} \
-/* END OF DEF */
+/* END OF DEF */ \ No newline at end of file