Camera2: Use lower resolutions for front fake camera. DO NOT MERGE
To differentiate front/back fake camera, support a lower set of resolutions for the front camera processed and jpeg streams. Bug: 6243944 Change-Id: I4a8746500944f7b445e0e5f0a3f441885733a7a4
This commit is contained in:
@@ -48,20 +48,31 @@ const uint64_t EmulatedFakeCamera2::kAvailableRawMinDurations[1] = {
|
||||
Sensor::kFrameDurationRange[0]
|
||||
};
|
||||
|
||||
const uint32_t EmulatedFakeCamera2::kAvailableProcessedSizes[4] = {
|
||||
const uint32_t EmulatedFakeCamera2::kAvailableProcessedSizesBack[4] = {
|
||||
640, 480, 320, 240
|
||||
// Sensor::kResolution[0], Sensor::kResolution[1]
|
||||
};
|
||||
|
||||
const uint32_t EmulatedFakeCamera2::kAvailableProcessedSizesFront[4] = {
|
||||
320, 240, 160, 120
|
||||
// Sensor::kResolution[0], Sensor::kResolution[1]
|
||||
};
|
||||
|
||||
const uint64_t EmulatedFakeCamera2::kAvailableProcessedMinDurations[1] = {
|
||||
Sensor::kFrameDurationRange[0]
|
||||
};
|
||||
|
||||
const uint32_t EmulatedFakeCamera2::kAvailableJpegSizes[2] = {
|
||||
const uint32_t EmulatedFakeCamera2::kAvailableJpegSizesBack[2] = {
|
||||
640, 480
|
||||
// Sensor::kResolution[0], Sensor::kResolution[1]
|
||||
};
|
||||
|
||||
const uint32_t EmulatedFakeCamera2::kAvailableJpegSizesFront[2] = {
|
||||
320, 240
|
||||
// Sensor::kResolution[0], Sensor::kResolution[1]
|
||||
};
|
||||
|
||||
|
||||
const uint64_t EmulatedFakeCamera2::kAvailableJpegMinDurations[1] = {
|
||||
Sensor::kFrameDurationRange[0]
|
||||
};
|
||||
@@ -265,15 +276,21 @@ int EmulatedFakeCamera2::allocateStream(
|
||||
availableSizeCount = sizeof(kAvailableRawSizes)/sizeof(uint32_t);
|
||||
break;
|
||||
case HAL_PIXEL_FORMAT_BLOB:
|
||||
availableSizes = kAvailableJpegSizes;
|
||||
availableSizeCount = sizeof(kAvailableJpegSizes)/sizeof(uint32_t);
|
||||
availableSizes = mFacingBack ?
|
||||
kAvailableJpegSizesBack : kAvailableJpegSizesFront;
|
||||
availableSizeCount = mFacingBack ?
|
||||
sizeof(kAvailableJpegSizesBack)/sizeof(uint32_t) :
|
||||
sizeof(kAvailableJpegSizesFront)/sizeof(uint32_t);
|
||||
break;
|
||||
case GRALLOC_EMULATOR_PIXEL_FORMAT_AUTO:
|
||||
case HAL_PIXEL_FORMAT_RGBA_8888:
|
||||
case HAL_PIXEL_FORMAT_YV12:
|
||||
case HAL_PIXEL_FORMAT_YCrCb_420_SP:
|
||||
availableSizes = kAvailableProcessedSizes;
|
||||
availableSizeCount = sizeof(kAvailableProcessedSizes)/sizeof(uint32_t);
|
||||
availableSizes = mFacingBack ?
|
||||
kAvailableProcessedSizesBack : kAvailableProcessedSizesFront;
|
||||
availableSizeCount = mFacingBack ?
|
||||
sizeof(kAvailableProcessedSizesBack)/sizeof(uint32_t) :
|
||||
sizeof(kAvailableProcessedSizesFront)/sizeof(uint32_t);
|
||||
break;
|
||||
default:
|
||||
ALOGE("%s: Unknown format 0x%x", __FUNCTION__, format);
|
||||
@@ -778,7 +795,6 @@ bool EmulatedFakeCamera2::ConfigureThread::threadLoop() {
|
||||
Mutex::Autolock lock(mInputMutex);
|
||||
mRequestCount--;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1012,6 +1028,7 @@ bool EmulatedFakeCamera2::ReadoutThread::threadLoop() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (compressedBufferIndex == -1) {
|
||||
delete mBuffers;
|
||||
mBuffers = NULL;
|
||||
@@ -1172,17 +1189,29 @@ status_t EmulatedFakeCamera2::constructStaticInfo(
|
||||
kAvailableRawMinDurations,
|
||||
sizeof(kAvailableRawMinDurations)/sizeof(uint64_t));
|
||||
|
||||
ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES,
|
||||
kAvailableProcessedSizes,
|
||||
sizeof(kAvailableProcessedSizes)/sizeof(uint32_t));
|
||||
if (mFacingBack) {
|
||||
ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES,
|
||||
kAvailableProcessedSizesBack,
|
||||
sizeof(kAvailableProcessedSizesBack)/sizeof(uint32_t));
|
||||
} else {
|
||||
ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES,
|
||||
kAvailableProcessedSizesFront,
|
||||
sizeof(kAvailableProcessedSizesFront)/sizeof(uint32_t));
|
||||
}
|
||||
|
||||
ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_PROCESSED_MIN_DURATIONS,
|
||||
kAvailableProcessedMinDurations,
|
||||
sizeof(kAvailableProcessedMinDurations)/sizeof(uint64_t));
|
||||
|
||||
ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_JPEG_SIZES,
|
||||
kAvailableJpegSizes,
|
||||
sizeof(kAvailableJpegSizes)/sizeof(uint32_t));
|
||||
if (mFacingBack) {
|
||||
ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_JPEG_SIZES,
|
||||
kAvailableJpegSizesBack,
|
||||
sizeof(kAvailableJpegSizesBack)/sizeof(uint32_t));
|
||||
} else {
|
||||
ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_JPEG_SIZES,
|
||||
kAvailableJpegSizesFront,
|
||||
sizeof(kAvailableJpegSizesFront)/sizeof(uint32_t));
|
||||
}
|
||||
|
||||
ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_JPEG_MIN_DURATIONS,
|
||||
kAvailableJpegMinDurations,
|
||||
@@ -1196,9 +1225,8 @@ status_t EmulatedFakeCamera2::constructStaticInfo(
|
||||
|
||||
static const int32_t jpegThumbnailSizes[] = {
|
||||
160, 120,
|
||||
320, 240,
|
||||
640, 480
|
||||
};
|
||||
320, 240
|
||||
};
|
||||
ADD_OR_SIZE(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES,
|
||||
jpegThumbnailSizes, sizeof(jpegThumbnailSizes)/sizeof(int32_t));
|
||||
|
||||
|
||||
@@ -255,9 +255,11 @@ private:
|
||||
static const uint32_t kAvailableFormats[];
|
||||
static const uint32_t kAvailableRawSizes[];
|
||||
static const uint64_t kAvailableRawMinDurations[];
|
||||
static const uint32_t kAvailableProcessedSizes[];
|
||||
static const uint32_t kAvailableProcessedSizesBack[];
|
||||
static const uint32_t kAvailableProcessedSizesFront[];
|
||||
static const uint64_t kAvailableProcessedMinDurations[];
|
||||
static const uint32_t kAvailableJpegSizes[];
|
||||
static const uint32_t kAvailableJpegSizesBack[];
|
||||
static const uint32_t kAvailableJpegSizesFront[];
|
||||
static const uint64_t kAvailableJpegMinDurations[];
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -394,7 +394,7 @@ void Sensor::captureRGBA(uint8_t *img, uint32_t gain, uint32_t stride) {
|
||||
float totalGain = gain/100.0 * kBaseGainFactor;
|
||||
// In fixed-point math, calculate total scaling from electrons to 8bpp
|
||||
int scale64x = 64 * totalGain * 255 / kMaxRawValue;
|
||||
uint32_t inc = (stride == 320) ? 2 : 1;
|
||||
uint32_t inc = kResolution[0] / stride;
|
||||
|
||||
for (unsigned int y = 0, outY = 0; y < kResolution[1]; y+=inc, outY++ ) {
|
||||
uint8_t *px = img + outY * stride * 4;
|
||||
@@ -411,7 +411,8 @@ void Sensor::captureRGBA(uint8_t *img, uint32_t gain, uint32_t stride) {
|
||||
*px++ = gCount < 255*64 ? gCount / 64 : 255;
|
||||
*px++ = bCount < 255*64 ? bCount / 64 : 255;
|
||||
*px++ = 255;
|
||||
if (inc == 2) mScene.getPixelElectrons();
|
||||
for (unsigned int j = 1; j < inc; j++)
|
||||
mScene.getPixelElectrons();
|
||||
}
|
||||
// TODO: Handle this better
|
||||
//simulatedTime += kRowReadoutTime;
|
||||
@@ -423,7 +424,7 @@ void Sensor::captureRGB(uint8_t *img, uint32_t gain, uint32_t stride) {
|
||||
float totalGain = gain/100.0 * kBaseGainFactor;
|
||||
// In fixed-point math, calculate total scaling from electrons to 8bpp
|
||||
int scale64x = 64 * totalGain * 255 / kMaxRawValue;
|
||||
uint32_t inc = (stride == 320) ? 2 : 1;
|
||||
uint32_t inc = kResolution[0] / stride;
|
||||
|
||||
for (unsigned int y = 0, outY = 0; y < kResolution[1]; y += inc, outY++ ) {
|
||||
mScene.setReadoutPixel(0, y);
|
||||
@@ -439,7 +440,8 @@ void Sensor::captureRGB(uint8_t *img, uint32_t gain, uint32_t stride) {
|
||||
*px++ = rCount < 255*64 ? rCount / 64 : 255;
|
||||
*px++ = gCount < 255*64 ? gCount / 64 : 255;
|
||||
*px++ = bCount < 255*64 ? bCount / 64 : 255;
|
||||
if (inc == 2) mScene.getPixelElectrons();
|
||||
for (unsigned int j = 1; j < inc; j++)
|
||||
mScene.getPixelElectrons();
|
||||
}
|
||||
// TODO: Handle this better
|
||||
//simulatedTime += kRowReadoutTime;
|
||||
@@ -453,7 +455,7 @@ void Sensor::captureNV21(uint8_t *img, uint32_t gain, uint32_t stride) {
|
||||
int scale64x = 64 * totalGain * 255 / kMaxRawValue;
|
||||
|
||||
// TODO: Make full-color
|
||||
uint32_t inc = (stride == 320) ? 2 : 1;
|
||||
uint32_t inc = kResolution[0] / stride;
|
||||
uint32_t outH = kResolution[1] / inc;
|
||||
for (unsigned int y = 0, outY = 0, outUV = outH;
|
||||
y < kResolution[1]; y+=inc, outY++, outUV ) {
|
||||
@@ -468,7 +470,8 @@ void Sensor::captureNV21(uint8_t *img, uint32_t gain, uint32_t stride) {
|
||||
bCount = pixel[Scene::B] * scale64x;
|
||||
uint32_t avg = (rCount + gCount + bCount) / 3;
|
||||
*pxY++ = avg < 255*64 ? avg / 64 : 255;
|
||||
if (inc == 2) mScene.getPixelElectrons();
|
||||
for (unsigned int j = 1; j < inc; j++)
|
||||
mScene.getPixelElectrons();
|
||||
}
|
||||
}
|
||||
for (unsigned int y = 0, outY = outH; y < kResolution[1]/2; y+=inc, outY++) {
|
||||
|
||||
Reference in New Issue
Block a user