1 // Copyright 2016 The Android Open Source Project 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef __GOLDFISH_FORMATCONVERSIONS_H__ 16 #define __GOLDFISH_FORMATCONVERSIONS_H__ 17 18 #include <inttypes.h> 19 20 // format conversions and helper functions 21 bool gralloc_is_yuv_format(int format); // e.g. HAL_PIXEL_FORMAT_YCbCr_420_888 22 23 void get_yv12_offsets(int width, int height, 24 uint32_t* yStride_out, 25 uint32_t* cStride_out, 26 uint32_t* totalSz_out); 27 void get_yuv420p_offsets(int width, int height, 28 uint32_t* yStride_out, 29 uint32_t* cStride_out, 30 uint32_t* totalSz_out); 31 signed clamp_rgb(signed value); 32 void rgb565_to_yv12(char* dest, char* src, int width, int height, 33 int left, int top, int right, int bottom); 34 void rgb888_to_yv12(char* dest, char* src, int width, int height, 35 int left, int top, int right, int bottom); 36 void rgb888_to_yuv420p(char* dest, char* src, int width, int height, 37 int left, int top, int right, int bottom); 38 void yv12_to_rgb565(char* dest, char* src, int width, int height, 39 int left, int top, int right, int bottom); 40 void yv12_to_rgb888(char* dest, char* src, int width, int height, 41 int left, int top, int right, int bottom); 42 void yuv420p_to_rgb888(char* dest, char* src, int width, int height, 43 int left, int top, int right, int bottom); 44 void copy_rgb_buffer_from_unlocked(char* _dst, const char* raw_data, 45 int unlockedWidth, 46 int width, int height, int top, int left, 47 int bpp); 48 #endif 49