am 4d7f7de7: Use actual JPEG quality when compressing picture

* commit '4d7f7de7007c7effd2518e581275fef32536c862':
  Use actual JPEG quality when compressing picture
This commit is contained in:
Vladimir Chtchetkine
2011-09-21 15:55:25 -07:00
committed by Android Git Automerger
3 changed files with 20 additions and 1 deletions

View File

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

View File

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

View File

@@ -322,6 +322,11 @@ status_t EmulatedCamera::takePicture()
LOGE("%s: Unsupported pixel format %s", __FUNCTION__, pix_fmt); LOGE("%s: Unsupported pixel format %s", __FUNCTION__, pix_fmt);
return EINVAL; 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 * Make sure preview is not running, and device is stopped before taking
@@ -358,6 +363,7 @@ status_t EmulatedCamera::takePicture()
} }
/* Deliver one frame only. */ /* Deliver one frame only. */
mCallbackNotifier.setJpegQuality(jpeg_quality);
mCallbackNotifier.setTakingPicture(true); mCallbackNotifier.setTakingPicture(true);
res = camera_dev->startDeliveringFrames(true); res = camera_dev->startDeliveringFrames(true);
if (res != NO_ERROR) { if (res != NO_ERROR) {