1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ANDROID_CAMERA_CAMERA_FORMAT_CONVERTERS_H 18 #define ANDROID_CAMERA_CAMERA_FORMAT_CONVERTERS_H 19 20 /* 21 * Contains declaration of the API that allows converting frames from one 22 * pixel format to another. 23 * 24 * For the emulator, we really need to convert into two formats: YV12, which is 25 * used by the camera framework for video, and RGB32 for preview window. 26 */ 27 28 #include "camera-common.h" 29 30 /* Checks if conversion between two pixel formats is available. 31 * Param: 32 * from - Pixel format to convert from. 33 * to - Pixel format to convert to. 34 * Return: 35 * boolean: 1 if converter is available, or 0 if no conversion exists. 36 */ 37 extern int has_converter(uint32_t from, uint32_t to); 38 39 /* Converts a frame into multiple framebuffers. 40 * When camera service replies to a framebuffer request from the client, it 41 * usualy sends two framebuffers in the reply: one for video, and another for 42 * preview window. Since these two framebuffers have different pixel formats 43 * (most of the time), we need to do two conversions for each frame received from 44 * the camera. This is the main intention behind this routine: to have a one call 45 * that produces as many conversions as needed. 46 * Param: 47 * frame - Frame to convert. 48 * pixel_format - Defines pixel format for the converting framebuffer. 49 * framebuffer_size, width, height - Converting framebuffer byte size, width, 50 * and height. 51 * framebuffers - Array of framebuffers where to convert the frame. Size of this 52 * array is defined by the 'fbs_num' parameter. Note that the caller must 53 * make sure that buffers are large enough to contain entire frame captured 54 * from the device. 55 * fbs_num - Number of entries in the 'framebuffers' array. 56 * Return: 57 * 0 on success, or non-zero value on failure. 58 */ 59 extern int convert_frame(const void* frame, 60 uint32_t pixel_format, 61 size_t framebuffer_size, 62 int width, 63 int height, 64 ClientFrameBuffer* framebuffers, 65 int fbs_num); 66 67 #endif /* ANDROID_CAMERA_CAMERA_FORMAT_CONVERTERS_H */ 68