aboutsummaryrefslogtreecommitdiffstats
path: root/android/camera
diff options
context:
space:
mode:
authorVladimir Chtchetkine <vchtchetkine@google.com>2012-02-22 10:19:54 -0800
committerVladimir Chtchetkine <vchtchetkine@google.com>2012-02-22 10:19:54 -0800
commita3338e7214cd0c69912866c6d71d8700c6ab35e2 (patch)
treedc2bd98e0f0e8dce63a16f69b73e7c9eb90d8250 /android/camera
parent4a795dda3d916c591206d2c37d6b583098204108 (diff)
downloadexternal_qemu-a3338e7214cd0c69912866c6d71d8700c6ab35e2.zip
external_qemu-a3338e7214cd0c69912866c6d71d8700c6ab35e2.tar.gz
external_qemu-a3338e7214cd0c69912866c6d71d8700c6ab35e2.tar.bz2
Fixes camera RTE on Windows
The root of the issue was that some cameras / camera drivers don't set compression type in the bitmap header explicitly to a V4L2_XXX, but set it to BI_RGB, which is unknown value for frame converters. To fix this, this CL converts BI_RGB to an appropriate V4L2_XXX value. Change-Id: Ifd70aa44138ab38fe66e8c80806a7dbb91725cf2
Diffstat (limited to 'android/camera')
-rwxr-xr-xandroid/camera/camera-capture-windows.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/android/camera/camera-capture-windows.c b/android/camera/camera-capture-windows.c
index 5479e23..e1c5538 100755
--- a/android/camera/camera-capture-windows.c
+++ b/android/camera/camera-capture-windows.c
@@ -223,6 +223,20 @@ _on_captured_frame(HWND hwnd, LPVIDEOHDR hdr)
/* Copy captured frame. */
memcpy(wcd->last_frame, hdr->lpData, hdr->dwBytesUsed);
+ /* If biCompression is set to default (RGB), set correct pixel format
+ * for converters. */
+ if (wcd->frame_bitmap->bmiHeader.biCompression == BI_RGB) {
+ if (wcd->frame_bitmap->bmiHeader.biBitCount == 32) {
+ wcd->pixel_format = V4L2_PIX_FMT_BGR32;
+ } else if (wcd->frame_bitmap->bmiHeader.biBitCount == 16) {
+ wcd->pixel_format = V4L2_PIX_FMT_RGB565;
+ } else {
+ wcd->pixel_format = V4L2_PIX_FMT_BGR24;
+ }
+ } else {
+ wcd->pixel_format = wcd->frame_bitmap->bmiHeader.biCompression;
+ }
+
return (LRESULT)0;
}
@@ -549,7 +563,7 @@ _camera_device_read_frame_callback(WndCameraDevice* wcd,
/* Convert framebuffer. */
return convert_frame(wcd->last_frame,
- wcd->frame_bitmap->bmiHeader.biCompression,
+ wcd->pixel_format,
wcd->frame_bitmap->bmiHeader.biSizeImage,
wcd->frame_bitmap->bmiHeader.biWidth,
wcd->frame_bitmap->bmiHeader.biHeight,