Commit | Line | Data |
---|---|---|
3719602c PC |
1 | /* Copyright (C) 2010-2020 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_pos; | |
58 | int filter_len; | |
59 | int filter_stride; | |
60 | }; | |
61 | ||
62 | struct scaler_ctx | |
63 | { | |
64 | void (*scaler_horiz)(const struct scaler_ctx*, | |
65 | const void*, int); | |
66 | void (*scaler_vert)(const struct scaler_ctx*, | |
67 | void*, int); | |
68 | void (*scaler_special)(const struct scaler_ctx*, | |
69 | void*, const void*, int, int, int, int, int, int); | |
70 | ||
71 | void (*in_pixconv)(void*, const void*, int, int, int, int); | |
72 | void (*out_pixconv)(void*, const void*, int, int, int, int); | |
73 | void (*direct_pixconv)(void*, const void*, int, int, int, int); | |
74 | struct scaler_filter horiz, vert; /* ptr alignment */ | |
75 | ||
76 | struct | |
77 | { | |
78 | uint32_t *frame; | |
79 | int stride; | |
80 | } input; | |
81 | ||
82 | struct | |
83 | { | |
84 | uint64_t *frame; | |
85 | int width; | |
86 | int height; | |
87 | int stride; | |
88 | } scaled; | |
89 | ||
90 | struct | |
91 | { | |
92 | uint32_t *frame; | |
93 | int stride; | |
94 | } output; | |
95 | ||
96 | int in_width; | |
97 | int in_height; | |
98 | int in_stride; | |
99 | ||
100 | int out_width; | |
101 | int out_height; | |
102 | int out_stride; | |
103 | ||
104 | enum scaler_pix_fmt in_fmt; | |
105 | enum scaler_pix_fmt out_fmt; | |
106 | enum scaler_type scaler_type; | |
107 | ||
108 | bool unscaled; | |
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 |