1 /* Copyright 2022 Advanced Micro Devices, Inc. 2 * 3 * Permission is hereby granted, free of charge, to any person obtaining a 4 * copy of this software and associated documentation files (the "Software"), 5 * to deal in the Software without restriction, including without limitation 6 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 * and/or sell copies of the Software, and to permit persons to whom the 8 * Software is furnished to do so, subject to the following conditions: 9 * 10 * The above copyright notice and this permission notice shall be included in 11 * all copies or substantial portions of the Software. 12 * 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 17 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 18 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 19 * OTHER DEALINGS IN THE SOFTWARE. 20 * 21 * Authors: AMD 22 * 23 */ 24 25 #pragma once 26 27 #include <string.h> 28 #include "vpe_types.h" 29 #include "color.h" 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 #define ADDR_LO(addr) ((addr) & 0xFFFFFFFF) 36 #define ADDR_HI(addr) (((addr) >> 32) & 0xFFFFFFFF) 37 38 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) 39 40 #define swap(x, y) \ 41 do { \ 42 unsigned char swap_temp[sizeof(x) == sizeof(y) ? (signed int)sizeof(x) : -1]; \ 43 memcpy(swap_temp, &y, sizeof(x)); \ 44 y = x; \ 45 memcpy(&x, swap_temp, sizeof(x)); \ 46 } while (0) 47 48 #ifndef min 49 #define min(x, y) (((x) < (y)) ? (x) : (y)) 50 #endif 51 52 #ifndef max 53 #define max(x, y) (((x) > (y)) ? (x) : (y)) 54 #endif 55 56 bool vpe_find_color_space_from_table( 57 const struct vpe_color_space *table, int table_size, const struct vpe_color_space *cs); 58 59 bool vpe_is_dual_plane_format(enum vpe_surface_pixel_format format); 60 61 // RGB checkers 62 bool vpe_is_32bit_packed_rgb(enum vpe_surface_pixel_format format); 63 bool vpe_is_rgb8(enum vpe_surface_pixel_format format); 64 bool vpe_is_rgb10(enum vpe_surface_pixel_format format); 65 bool vpe_is_fp16(enum vpe_surface_pixel_format format); 66 67 // yuv 4:2:0 check 68 bool vpe_is_yuv420_8(enum vpe_surface_pixel_format format); 69 bool vpe_is_yuv420_10(enum vpe_surface_pixel_format format); 70 bool vpe_is_yuv420_16(enum vpe_surface_pixel_format format); 71 bool vpe_is_yuv420(enum vpe_surface_pixel_format format); 72 73 // yuv 4:4:4 check 74 bool vpe_is_yuv444_8(enum vpe_surface_pixel_format format); 75 bool vpe_is_yuv444_10(enum vpe_surface_pixel_format format); 76 bool vpe_is_yuv444(enum vpe_surface_pixel_format format); 77 78 enum color_depth vpe_get_color_depth(enum vpe_surface_pixel_format format); 79 80 bool vpe_has_per_pixel_alpha(enum vpe_surface_pixel_format format); 81 82 enum vpe_status vpe_check_output_support(struct vpe *vpe, const struct vpe_build_param *param); 83 84 enum vpe_status vpe_check_input_support(struct vpe *vpe, const struct vpe_stream *stream); 85 86 enum vpe_status vpe_check_tone_map_support( 87 struct vpe *vpe, const struct vpe_stream *stream, const struct vpe_build_param *param); 88 89 #ifdef __cplusplus 90 } 91 #endif 92