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:
@@ -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);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user