1 /* Copyright (C) 2010-2018 The RetroArch team 2 * 3 * --------------------------------------------------------------------------------------- 4 * The following license statement only applies to this file (scaler.h). 5 * --------------------------------------------------------------------------------------- 6 * 7 * Permission is hereby granted, free of charge, 8 * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 * to deal in the Software without restriction, including without limitation the rights to 10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 23 #ifndef __LIBRETRO_SDK_SCALER_H__ 24 #define __LIBRETRO_SDK_SCALER_H__ 25 26 #include <stdint.h> 27 #include <stddef.h> 28 #include <boolean.h> 29 #include <clamping.h> 30 31 #include <retro_common_api.h> 32 33 RETRO_BEGIN_DECLS 34 35 enum scaler_pix_fmt 36 { 37 SCALER_FMT_ARGB8888 = 0, 38 SCALER_FMT_ABGR8888, 39 SCALER_FMT_0RGB1555, 40 SCALER_FMT_RGB565, 41 SCALER_FMT_BGR24, 42 SCALER_FMT_YUYV, 43 SCALER_FMT_RGBA4444 44 }; 45 46 enum scaler_type 47 { 48 SCALER_TYPE_UNKNOWN = 0, 49 SCALER_TYPE_POINT, 50 SCALER_TYPE_BILINEAR, 51 SCALER_TYPE_SINC 52 }; 53 54 struct scaler_filter 55 { 56 int16_t *filter; 57 int filter_len; 58 int filter_stride; 59 int *filter_pos; 60 }; 61 62 struct scaler_ctx 63 { 64 int in_width; 65 int in_height; 66 int in_stride; 67 68 int out_width; 69 int out_height; 70 int out_stride; 71 72 enum scaler_pix_fmt in_fmt; 73 enum scaler_pix_fmt out_fmt; 74 enum scaler_type scaler_type; 75 76 void (*scaler_horiz)(const struct scaler_ctx*, 77 const void*, int); 78 void (*scaler_vert)(const struct scaler_ctx*, 79 void*, int); 80 void (*scaler_special)(const struct scaler_ctx*, 81 void*, const void*, int, int, int, int, int, int); 82 83 void (*in_pixconv)(void*, const void*, int, int, int, int); 84 void (*out_pixconv)(void*, const void*, int, int, int, int); 85 void (*direct_pixconv)(void*, const void*, int, int, int, int); 86 87 bool unscaled; 88 struct scaler_filter horiz, vert; 89 90 struct 91 { 92 uint32_t *frame; 93 int stride; 94 } input; 95 96 struct 97 { 98 uint64_t *frame; 99 int width; 100 int height; 101 int stride; 102 } scaled; 103 104 struct 105 { 106 uint32_t *frame; 107 int stride; 108 } output; 109 }; 110 111 bool scaler_ctx_gen_filter(struct scaler_ctx *ctx); 112 113 void scaler_ctx_gen_reset(struct scaler_ctx *ctx); 114 115 /** 116 * scaler_ctx_scale: 117 * @ctx : pointer to scaler context object. 118 * @output : pointer to output image. 119 * @input : pointer to input image. 120 * 121 * Scales an input image to an output image. 122 **/ 123 void scaler_ctx_scale(struct scaler_ctx *ctx, 124 void *output, const void *input); 125 126 RETRO_END_DECLS 127 128 #endif 129