New Camera modif. Now calculating good size for jpeg

Change-Id: Iea267ac432b90cd42cf5a1e9c57320d9a2b4aefd
This commit is contained in:
KalimochoAz 2011-02-12 16:26:48 +01:00 committed by Steve Kondik
parent 1e5dde8899
commit 1eef237652
5 changed files with 21 additions and 18 deletions

View File

@ -32,6 +32,8 @@
#include <linux/ioctl.h>
#include "raw2jpeg.h"
// #define iLog(fmt, args...) LOGD(fmt, ##args)
#define LIKELY(exp) __builtin_expect(!!(exp), 1)
#define UNLIKELY(exp) __builtin_expect(!!(exp), 0)
@ -850,19 +852,19 @@ void QualcommCameraHardware::runJpegEncodeThread(void *data)
npt = NULL ;
}
writeExif( mRawHeap->mHeap->base(), mJpegHeap->mHeap->base(), mJpegSize, &mJpegSize, rotation , npt );
// writeExif( mRawHeap->mHeap->base(), mJpegHeap->mHeap->base(), mJpegSize, &mJpegSize, rotation , npt );
int jpeg_quality = mParameters.getInt("jpeg-quality");
LOGV("Kalim: Inicio conversion a JPEG ----------------------------------------------------------------------------------------------");
LOGV("KalimochoAz jpeg convert, current jpeg main img quality =%d", jpeg_quality);
LOGV("KalimochoAz jpeg convert, current jpeg main img Height =%d", mRawHeight);
LOGV("KalimochoAz jpeg convert, current jpeg main img Width =%d", mRawWidth);
if( yuv420_save2jpeg((unsigned char*) mJpegHeap->mHeap->base(), mRawHeap->mHeap->base(), mRawWidth, mRawHeight, jpeg_quality) )
LOGD("Kalim: Inicio conversion a JPEG ----------------------------------------------------------------------------------------------");
LOGD("KalimochoAz jpeg convert, current jpeg main img quality =%d", jpeg_quality);
LOGD("KalimochoAz jpeg convert, current jpeg main img Height =%d", mRawHeight);
LOGD("KalimochoAz jpeg convert, current jpeg main img Width =%d", mRawWidth);
if( yuv420_save2jpeg((unsigned char*) mJpegHeap->mHeap->base(), mRawHeap->mHeap->base(), mRawWidth, mRawHeight, jpeg_quality, &mJpegSize) )
LOGV("Kalim: JpegConvetida Correctamente ***********************************************************************************************************");
else
LOGV("Kalim: Fallo de conversion a JPEG xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
LOGD("KalimochoAz jpeg convert, current jpeg main img jpegSize =%d ........", mJpegSize);
receiveJpegPicture();
}
@ -1606,9 +1608,9 @@ CameraParameters QualcommCameraHardware::getParameters() const
extern "C" sp<CameraHardwareInterface> openCameraHardware()
{
LOGV("*-------------------------------------------------------------------------------------*");
LOGV("[M a@openCameraHardware: call createInstance v: %s",version);
LOGV("*-------------------------------------------------------------------------------------*");
LOGD("*-------------------------------------------------------------------------------------*");
LOGD("[M a@openCameraHardware: call createInstance v: %s",version);
LOGD("*-------------------------------------------------------------------------------------*");
return QualcommCameraHardware::createInstance();
}

View File

@ -28,7 +28,7 @@ extern "C" {
#include "msm_camera.h"
}
#define version "10.12.11"
#define version "11.04.01"
#define MSM_CAMERA_CONTROL "/dev/msm_camera/msm_camera0"
#define JPEG_EVENT_DONE 0 /* guess */

View File

@ -29,11 +29,10 @@ YuvToJpegEncoder::YuvToJpegEncoder(int* strides) : fStrides(strides) {
}
bool YuvToJpegEncoder::encode(unsigned char* dest, void* inYuv, int width,
int height, int* offsets, int jpegQuality) {
int height, int* offsets, int jpegQuality, uint32_t* mSize) {
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
long unsigned int image_size;
unsigned char* ucDest;
// Warning, this is ONLY valid for YUV420SP (ImageFormat.NV21 in android)
image_size = (width*height*1.5);
@ -53,6 +52,8 @@ bool YuvToJpegEncoder::encode(unsigned char* dest, void* inYuv, int width,
jpeg_finish_compress(&cinfo);
*mSize = (uint32_t) image_size;
mJpegTam = (uint32_t) image_size;
return true;
}
@ -145,7 +146,7 @@ void Yuv420SpToJpegEncoder::configSamplingFactors(jpeg_compress_struct* cinfo) {
///////////////////////////////////////////////////////////////////////////////
int yuv420_save2jpeg(unsigned char *dest, void *src, int width, int height, int quality) {
int yuv420_save2jpeg(unsigned char *dest, void *src, int width, int height, int quality, uint32_t *mSize) {
int imgStrides[2], imgOffsets[2];
// Convert the RAW data to JPEG
@ -159,7 +160,7 @@ int yuv420_save2jpeg(unsigned char *dest, void *src, int width, int height, int
// in android
imgOffsets[0] = 0;
imgOffsets[1] = width*height;
encoder->encode(dest, src, width, height, imgOffsets, quality);
encoder->encode(dest, src, width, height, imgOffsets, quality, mSize);
delete encoder;

View File

@ -29,8 +29,8 @@ public:
* @return true if successfully compressed the stream.
*/
bool encode(unsigned char* dest, void* inYuv, int width,
int height, int* offsets, int jpegQuality);
int height, int* offsets, int jpegQuality, uint32_t* mSize);
uint32_t mJpegTam;
virtual ~YuvToJpegEncoder() {}
protected:

View File

@ -1 +1 @@
int yuv420_save2jpeg(unsigned char *dest, void *src, int width, int height, int quality);
int yuv420_save2jpeg(unsigned char *dest, void *src, int width, int height, int quality, uint32_t *mSize);