summaryrefslogtreecommitdiff
authorguosong.zhou <guosong.zhou@amlogic.com>2014-11-04 11:29:39 (GMT)
committer guosong.zhou <guosong.zhou@amlogic.com>2014-11-04 11:29:39 (GMT)
commit88e27cb1b6b4a4412d82bd142836090864300365 (patch)
tree6ed6ba68444c1669d0990d9fe876c0db35b46b81
parent72316f95575b7c0520a036c0a3253bddeacf1a4c (diff)
downloadcamera-88e27cb1b6b4a4412d82bd142836090864300365.zip
camera-88e27cb1b6b4a4412d82bd142836090864300365.tar.gz
camera-88e27cb1b6b4a4412d82bd142836090864300365.tar.bz2
resolve repeat snapshot for cts
Diffstat
-rwxr-xr-xv3/EmulatedFakeCamera3.cpp9
-rwxr-xr-xv3/fake-pipeline2/JpegCompressor.cpp39
-rwxr-xr-xv3/fake-pipeline2/Sensor.cpp2
-rwxr-xr-xv3/fake-pipeline2/camera_hw.cpp2
4 files changed, 40 insertions, 12 deletions
diff --git a/v3/EmulatedFakeCamera3.cpp b/v3/EmulatedFakeCamera3.cpp
index b413af4..da0a1ce 100755
--- a/v3/EmulatedFakeCamera3.cpp
+++ b/v3/EmulatedFakeCamera3.cpp
@@ -1188,6 +1188,7 @@ status_t EmulatedFakeCamera3::processCaptureRequest(
/**
* Wait for JPEG compressor to not be busy, if needed
*/
+#if 0
if (needJpeg) {
bool ready = mJpegCompressor->waitForDone(kFenceTimeoutMs);
if (!ready) {
@@ -1196,7 +1197,13 @@ status_t EmulatedFakeCamera3::processCaptureRequest(
return NO_INIT;
}
}
-
+#else
+ while (needJpeg) {
+ bool ready = mJpegCompressor->waitForDone(kFenceTimeoutMs);
+ if (ready)
+ break;
+ }
+#endif
/**
* Wait until the in-flight queue has room
*/
diff --git a/v3/fake-pipeline2/JpegCompressor.cpp b/v3/fake-pipeline2/JpegCompressor.cpp
index c8e3ab7..4e01be7 100755
--- a/v3/fake-pipeline2/JpegCompressor.cpp
+++ b/v3/fake-pipeline2/JpegCompressor.cpp
@@ -25,6 +25,7 @@
#include "../EmulatedFakeCamera3.h"
#include <stdlib.h>
#include <math.h>
+#include <sys/time.h>
#define ARRAY_SIZE(array) (sizeof((array)) / sizeof((array)[0]))
const uint8_t MARK = 0xFF;
@@ -151,11 +152,14 @@ status_t JpegCompressor::readyToRun() {
bool JpegCompressor::threadLoop() {
status_t res;
+ struct timeval mTimeStart,mTimeend;
+ int intreval;
ExifElementsTable* exiftable = NULL;
struct camera2_jpeg_blob blob;
int offset;
ALOGV("%s: Starting compression thread", __FUNCTION__);
+ gettimeofday(&mTimeStart, NULL);
res = compress();
if (mNeedexif) {
memset(&blob,0,sizeof(struct camera2_jpeg_blob));
@@ -163,7 +167,8 @@ bool JpegCompressor::threadLoop() {
GenExif(exiftable);
res = thumbcompress();
}
- if (exiftable) {
+
+ if ((exiftable)&&(mDstThumbBuffer != NULL)) {
Section_t* exif_section = NULL;
ExifElementsTable* exif = exiftable;
exif->insertExifToJpeg((unsigned char*)mJpegBuffer.img,mMainJpegSize);
@@ -179,13 +184,16 @@ bool JpegCompressor::threadLoop() {
memcpy(mJpegBuffer.img+offset, &blob, sizeof(struct camera2_jpeg_blob));
}
mListener->onJpegDone(mJpegBuffer, res == OK);
-
+
if (mNeedexif) {
if (exiftable != NULL) {
delete exiftable;
exiftable = NULL;
}
}
+ gettimeofday(&mTimeend, NULL);
+ intreval = (mTimeend.tv_sec - mTimeStart.tv_sec) * 1000 + ((mTimeend.tv_usec - mTimeStart.tv_usec))/1000;
+ ALOGD("jpeg compress cost time =%d ms",intreval);
cleanUp();
return false;
@@ -194,8 +202,7 @@ bool JpegCompressor::threadLoop() {
status_t JpegCompressor::compress() {
// Find source and target buffers. Assumes only one buffer matches
// each condition!
-
- Mutex::Autolock lock(mMutex);
+ //Mutex::Autolock lock(mMutex);
bool foundJpeg = false, mFoundAux = false;
for (size_t i = 0; i < mBuffers->size(); i++) {
const StreamBuffer &b = (*mBuffers)[i];
@@ -215,14 +222,19 @@ status_t JpegCompressor::compress() {
}
if (mNeedexif == true) {
+ if (mSrcThumbBuffer == NULL) {
mSrcThumbBuffer = (uint8_t*)malloc(mInfo.thumbwidth*mInfo.thumbheight*3);
+ }
+ if (mDstThumbBuffer == NULL) {
mDstThumbBuffer = (uint8_t*)malloc(mInfo.thumbwidth*mInfo.thumbheight*3);
+ }
if (mSrcThumbBuffer) {
if (mAuxBuffer.format == HAL_PIXEL_FORMAT_RGB_888)
extraSmallImg(mAuxBuffer.img,mAuxBuffer.width,mAuxBuffer.height,
mSrcThumbBuffer,mInfo.thumbwidth,mInfo.thumbheight);
}
}
+
// Set up error management
mJpegErrorInfo = NULL;
@@ -288,7 +300,9 @@ status_t JpegCompressor::compress() {
}
status_t JpegCompressor::thumbcompress() {
- Mutex::Autolock lock(mMutex);
+ if ((mSrcThumbBuffer == NULL)||(mDstThumbBuffer == NULL))
+ return 0;
+ //Mutex::Autolock lock(mMutex);
mJpegErrorInfo = NULL;
JpegError error;
error.parent = this;
@@ -375,13 +389,18 @@ bool JpegCompressor::checkError(const char *msg) {
void JpegCompressor::cleanUp() {
status_t res;
jpeg_destroy_compress(&mCInfo);
- if (mNeedexif) {
+ Mutex::Autolock lock(mBusyMutex);
+ if (mNeedexif == true) {
mNeedexif = false;
- free(mSrcThumbBuffer);
- free(mDstThumbBuffer);
+ if (mSrcThumbBuffer != NULL) {
+ free(mSrcThumbBuffer);
+ mSrcThumbBuffer = NULL;
+ }
+ if (mDstThumbBuffer != NULL) {
+ free(mDstThumbBuffer);
+ mDstThumbBuffer = NULL;
+ }
}
- Mutex::Autolock lock(mBusyMutex);
-
if (mFoundAux) {
if (mAuxBuffer.streamId == 0) {
delete[] mAuxBuffer.img;
diff --git a/v3/fake-pipeline2/Sensor.cpp b/v3/fake-pipeline2/Sensor.cpp
index 1d36850..f8f6f9f 100755
--- a/v3/fake-pipeline2/Sensor.cpp
+++ b/v3/fake-pipeline2/Sensor.cpp
@@ -1423,7 +1423,7 @@ void Sensor::captureRGB(uint8_t *img, uint32_t gain, uint32_t stride) {
{
src = (uint8_t *)get_picture(vinfo);
if (NULL == src) {
- usleep(300000);
+ usleep(30000);
continue;
} else {
break;
diff --git a/v3/fake-pipeline2/camera_hw.cpp b/v3/fake-pipeline2/camera_hw.cpp
index 2bb9b7e..277bef3 100755
--- a/v3/fake-pipeline2/camera_hw.cpp
+++ b/v3/fake-pipeline2/camera_hw.cpp
@@ -65,6 +65,7 @@ int camera_open(struct VideoInfo *cam_dev)
int setBuffersFormat(struct VideoInfo *cam_dev)
{
int ret = 0;
+ if ((cam_dev->preview.format.fmt.pix.width != 0) && (cam_dev->preview.format.fmt.pix.height != 0)) {
int pixelformat = cam_dev->preview.format.fmt.pix.pixelformat;
ret = ioctl(cam_dev->fd, VIDIOC_S_FMT, &cam_dev->preview.format);
@@ -77,6 +78,7 @@ int setBuffersFormat(struct VideoInfo *cam_dev)
cam_dev->preview.format.fmt.pix.height,
(char*)&pixelformat,
(char*)&cam_dev->preview.format.fmt.pix.pixelformat);
+ }
return ret;
}