aboutsummaryrefslogtreecommitdiffstats
path: root/android/camera/camera-format-converters.h
diff options
context:
space:
mode:
authorVladimir Chtchetkine <vchtchetkine@google.com>2011-09-04 09:51:40 -0700
committerVladimir Chtchetkine <vchtchetkine@google.com>2011-09-12 12:12:57 -0700
commitcf1c2c70dd99e7d78816ba9a558f9ed8c016862b (patch)
tree0e6893eedea447e20ecdb7ad66f9f05cda65d7af /android/camera/camera-format-converters.h
parentc646f5e40ddda3d49b581ac0c78cf748b5dee74c (diff)
downloadexternal_qemu-cf1c2c70dd99e7d78816ba9a558f9ed8c016862b.zip
external_qemu-cf1c2c70dd99e7d78816ba9a558f9ed8c016862b.tar.gz
external_qemu-cf1c2c70dd99e7d78816ba9a558f9ed8c016862b.tar.bz2
Implements camera service in emulator
This is fully functional camera service implementation, that works (tested) on both, Linux and Windows. Fixed little/big endian bugs in the coverter code. Moved preview frames to use RGB32 instead of RGB565: RGB32 conversions are simpler and faster in the guest. Made "payload size send" a separate routine Change-Id: I96954f4c2cb4e4ef4dd6a20e41897d79c5037bae
Diffstat (limited to 'android/camera/camera-format-converters.h')
-rwxr-xr-xandroid/camera/camera-format-converters.h52
1 files changed, 34 insertions, 18 deletions
diff --git a/android/camera/camera-format-converters.h b/android/camera/camera-format-converters.h
index 797ad48..6f1b492 100755
--- a/android/camera/camera-format-converters.h
+++ b/android/camera/camera-format-converters.h
@@ -20,32 +20,48 @@
/*
* Contains declaration of the API that allows converting frames from one
* pixel format to another.
+ *
+ * For the emulator, we really need to convert into two formats: YV12, which is
+ * used by the camera framework for video, and RGB32 for preview window.
*/
#include "camera-common.h"
-/* Prototype of a routine that converts frame from one pixel format to another.
- * Param:
- * from - Frame to convert.
- * width, height - Width, and height of the frame to convert.
- * to - Buffer to receive the converted frame. Note that this buffer must
- * be big enough to contain all the converted pixels!
- */
-typedef void (*FormatConverter)(const uint8_t* from,
- int width,
- int height,
- uint8_t* to);
-
-
-/* Gets an address of a routine that provides frame conversion for the
- * given pixel format.
+/* Checks if conversion between two pixel formats is available.
* Param:
* from - Pixel format to convert from.
* to - Pixel format to convert to.
* Return:
- * Address of an appropriate conversion routine, or NULL if no conversion
- * routine exsits for the given pair of pixel formats.
+ * boolean: 1 if converter is available, or 0 if no conversion exists.
*/
-extern FormatConverter get_format_converted(uint32_t from, uint32_t to);
+extern int has_converter(uint32_t from, uint32_t to);
+
+/* Converts a frame into multiple framebuffers.
+ * When camera service replies to a framebuffer request from the client, it
+ * usualy sends two framebuffers in the reply: one for video, and another for
+ * preview window. Since these two framebuffers have different pixel formats
+ * (most of the time), we need to do two conversions for each frame received from
+ * the camera. This is the main intention behind this routine: to have a one call
+ * that produces as many conversions as needed.
+ * Param:
+ * frame - Frame to convert.
+ * pixel_format - Defines pixel format for the converting framebuffer.
+ * framebuffer_size, width, height - Converting framebuffer byte size, width,
+ * and height.
+ * framebuffers - Array of framebuffers where to convert the frame. Size of this
+ * array is defined by the 'fbs_num' parameter. Note that the caller must
+ * make sure that buffers are large enough to contain entire frame captured
+ * from the device.
+ * fbs_num - Number of entries in the 'framebuffers' array.
+ * Return:
+ * 0 on success, or non-zero value on failure.
+*/
+extern int convert_frame(const void* frame,
+ uint32_t pixel_format,
+ size_t framebuffer_size,
+ int width,
+ int height,
+ ClientFrameBuffer* framebuffers,
+ int fbs_num);
#endif /* ANDROID_CAMERA_CAMERA_FORMAT_CONVERTERS_H */