Use actual JPEG quality when compressing picture

Sometimes framework chooses to override the default JPEG quality value (90), so we need to
respect that when compressing frame during picture taking.

Change-Id: Ic7ad8938d33d94d34ecd0b979e5c8c3e8246fd53
This commit is contained in:
Vladimir Chtchetkine
2011-09-21 15:33:18 -07:00
parent 68ec4ac828
commit 4d7f7de700
3 changed files with 20 additions and 1 deletions

View File

@@ -93,6 +93,7 @@ CallbackNotifier::CallbackNotifier()
mLastFrameTimestamp(0),
mFrameRefreshFreq(0),
mMessageEnabler(0),
mJpegQuality(90),
mVideoRecEnabled(false),
mTakingPicture(false)
{
@@ -196,7 +197,9 @@ void CallbackNotifier::cleanupCBNotifier()
mCBOpaque = NULL;
mLastFrameTimestamp = 0;
mFrameRefreshFreq = 0;
mJpegQuality = 90;
mVideoRecEnabled = false;
mTakingPicture = false;
}
void CallbackNotifier::onNextFrameAvailable(const void* frame,
@@ -235,7 +238,8 @@ void CallbackNotifier::onNextFrameAvailable(const void* frame,
NV21JpegCompressor compressor;
status_t res =
compressor.compressRawImage(frame, camera_dev->getFrameWidth(),
camera_dev->getFrameHeight(), 90);
camera_dev->getFrameHeight(),
mJpegQuality);
if (res == NO_ERROR) {
camera_memory_t* jpeg_buff =
mGetMemoryCB(-1, compressor.getCompressedSize(), 1, NULL);

View File

@@ -168,6 +168,12 @@ public:
mTakingPicture = taking;
}
/* Sets JPEG quality used to compress frame during picture taking. */
void setJpegQuality(int jpeg_quality)
{
mJpegQuality = jpeg_quality;
}
/****************************************************************************
* Private API
***************************************************************************/
@@ -206,6 +212,9 @@ protected:
/* Message enabler. */
uint32_t mMessageEnabler;
/* JPEG quality used to compress frame during picture taking. */
int mJpegQuality;
/* Video recording status. */
bool mVideoRecEnabled;

View File

@@ -322,6 +322,11 @@ status_t EmulatedCamera::takePicture()
LOGE("%s: Unsupported pixel format %s", __FUNCTION__, pix_fmt);
return EINVAL;
}
/* Get JPEG quality. */
int jpeg_quality = mParameters.getInt(CameraParameters::KEY_JPEG_QUALITY);
if (jpeg_quality <= 0) {
jpeg_quality = 90; /* Fall back to default. */
}
/*
* Make sure preview is not running, and device is stopped before taking
@@ -358,6 +363,7 @@ status_t EmulatedCamera::takePicture()
}
/* Deliver one frame only. */
mCallbackNotifier.setJpegQuality(jpeg_quality);
mCallbackNotifier.setTakingPicture(true);
res = camera_dev->startDeliveringFrames(true);
if (res != NO_ERROR) {