EmulatedFakeCamera2: Minor fixes
- Add some error checking
- Change default exposure/gain to avoid overexposure.
- Improve gain calculation for RGBA output
Bug: 6243944
Change-Id: Iaa9f35e0b62883a947cc9e63f86d0ec3ae828576
diff --git a/tools/emulator/system/camera/EmulatedFakeCamera2.cpp b/tools/emulator/system/camera/EmulatedFakeCamera2.cpp
index 633ad83..ef273ba 100644
--- a/tools/emulator/system/camera/EmulatedFakeCamera2.cpp
+++ b/tools/emulator/system/camera/EmulatedFakeCamera2.cpp
@@ -773,8 +773,13 @@
ALOGV("Sending image buffer to output stream.");
GraphicBufferMapper::get().unlock(*mBuffer);
- mParent->mRawStreamOps->enqueue_buffer(mParent->mRawStreamOps,
+ res = mParent->mRawStreamOps->enqueue_buffer(mParent->mRawStreamOps,
captureTime, mBuffer);
+ if (res != OK) {
+ ALOGE("Error enqueuing image buffer %p: %s (%d)", mBuffer,
+ strerror(-res), res);
+ // TODO: Should this cause a stop?
+ }
mBuffer = NULL;
return true;
@@ -1127,13 +1132,13 @@
/** android.sensor */
- static const int64_t exposureTime = 30 * MSEC;
+ static const int64_t exposureTime = 10 * MSEC;
ADD_OR_SIZE(ANDROID_SENSOR_EXPOSURE_TIME, &exposureTime, 1);
static const int64_t frameDuration = 33333333L; // 1/30 s
ADD_OR_SIZE(ANDROID_SENSOR_FRAME_DURATION, &frameDuration, 1);
- static const int32_t sensitivity = 400;
+ static const int32_t sensitivity = 100;
ADD_OR_SIZE(ANDROID_SENSOR_SENSITIVITY, &sensitivity, 1);
// TIMESTAMP set only in frame
diff --git a/tools/emulator/system/camera/fake-pipeline2/Sensor.cpp b/tools/emulator/system/camera/fake-pipeline2/Sensor.cpp
index 7ce6dab..bd4a656 100644
--- a/tools/emulator/system/camera/fake-pipeline2/Sensor.cpp
+++ b/tools/emulator/system/camera/fake-pipeline2/Sensor.cpp
@@ -386,10 +386,7 @@
void Sensor::captureRGBA(uint32_t gain, uint32_t stride,
uint8_t **capturedBuffer, nsecs_t captureTime, nsecs_t frameReadoutTime) {
- float totalGain = gain/100.0 * kBaseGainFactor;
- float noiseVarGain = totalGain * totalGain;
- float readNoiseVar = kReadNoiseVarBeforeGain * noiseVarGain
- + kReadNoiseVarAfterGain;
+ int totalGain = gain/100.0 * kBaseGainFactor;
for (unsigned int y = 0; y < kResolution[1]; y++ ) {
uint8_t *px = (uint8_t*)mNextCapturedBuffer + y * stride * 4;
@@ -397,13 +394,13 @@
uint32_t rCount, gCount, bCount;
// TODO: Perfect demosaicing is a cheat
const uint32_t *pixel = mScene.getPixelElectrons();
- rCount = pixel[Scene::R] * totalGain;
- gCount = pixel[Scene::Gr] * totalGain;
- bCount = pixel[Scene::B] * totalGain;
+ rCount = pixel[Scene::R] * totalGain / (kMaxRawValue / 255);
+ gCount = pixel[Scene::Gr] * totalGain / (kMaxRawValue / 255);
+ bCount = pixel[Scene::B] * totalGain / (kMaxRawValue / 255);
- *px++ = rCount / (kMaxRawValue / 255);
- *px++ = gCount / (kMaxRawValue / 255);
- *px++ = bCount / (kMaxRawValue / 255);
+ *px++ = rCount < 255 ? rCount : 255;
+ *px++ = gCount < 255 ? gCount : 255;
+ *px++ = bCount < 255 ? bCount : 255;
*px++ = 255;
}
// TODO: Handle this better