Bug 783682 - Camera - always assume the camera gives us yuv420sp [r=gal]

This commit is contained in:
Mike Habicher 2012-08-20 09:11:20 -07:00
Родитель ca755c3d2a
Коммит 3063ddba91
1 изменённых файлов: 21 добавлений и 1 удалений

Просмотреть файл

@ -26,6 +26,16 @@ using namespace mozilla;
using namespace mozilla::layers;
using namespace android;
/**
* See bug 783682. Most camera implementations, despite claiming they
* support 'yuv420p' as a preview format, actually ignore this setting
* and return 'yuv420sp' data anyway. We have come across a new implementation
* that, while reporting that 'yuv420p' is supported *and* has been accepted,
* still returns the frame data in 'yuv420sp' anyway. So for now, since
* everyone seems to return this format, we just force it.
*/
#define FORCE_PREVIEW_FORMAT_YUV420SP 1
#if GIHM_TIMING_RECEIVEFRAME
#define INCLUDE_TIME_H 1
#endif
@ -51,7 +61,11 @@ static __inline void timespecSubtract(struct timespec* a, struct timespec* b)
GonkCameraHardware::GonkCameraHardware(GonkCamera* aTarget, PRUint32 aCamera)
: mCamera(aCamera)
, mFps(30)
#if !FORCE_PREVIEW_FORMAT_YUV420SP
, mPreviewFormat(PREVIEW_FORMAT_UNKNOWN)
#else
, mPreviewFormat(PREVIEW_FORMAT_YUV420SP)
#endif
, mClosing(false)
, mMonitor("GonkCameraHardware.Monitor")
, mNumFrames(0)
@ -384,6 +398,7 @@ GonkCameraHardware::StartPreview()
{
const char* format;
#if !FORCE_PREVIEW_FORMAT_YUV420SP
DOM_CAMERA_LOGI("Preview formats: %s\n", mParams.get(mParams.KEY_SUPPORTED_PREVIEW_FORMATS));
// try to set preferred image format and frame rate
@ -405,6 +420,11 @@ GonkCameraHardware::StartPreview()
mPreviewFormat = PREVIEW_FORMAT_UNKNOWN;
DOM_CAMERA_LOGE("Camera ignored our request for '%s' preview, returned UNSUPPORTED format '%s'\n", PREVIEW_FORMAT, format);
}
#else
mParams.setPreviewFormat("yuv420sp");
mParams.setPreviewFrameRate(mFps);
mHardware->setParameters(mParams);
#endif
// Check the frame rate and log if the camera ignored our setting
PRUint32 fps = mParams.getPreviewFrameRate();