Raw ↗
+ +
5797689 fix(windows): resolve MSVC test linkage, missing unistd, and export declarations
saifmukhtar · 2026-11-24
1 /*
2 * SPDX-License-Identifier: AGPL-3.0-or-later WITH Classpath-exception-2.0
3 * Copyright (c) 2026 Saif Mukhtar
4 *
5 * OpenAVX - Open Audio-Video eXchange
6 * include/avx_color.h - Color format conversion and alpha blending
7 */
8  
9 #ifndef AVX_COLOR_H
10 #define AVX_COLOR_H
11  
12 #include <stdint.h>
13 #include <stddef.h>
14 #include <stdbool.h>
15 #include "openavx.h"
16  
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20  
21 /**
22 * Converts packed 4:2:2 UYVY to 32-bit packed RGBA (Alpha = 255).
23 */
24 OPENAVX_API void avx_color_uyvy_to_rgba(const uint8_t *src, uint8_t *dst, int width, int height);
25  
26 /**
27 * Converts packed 4:2:2 UYVY to 32-bit packed BGRA (Alpha = 255).
28 */
29 OPENAVX_API void avx_color_uyvy_to_bgra(const uint8_t *src, uint8_t *dst, int width, int height);
30  
31 /**
32 * Converts 32-bit packed RGBA to packed 4:2:2 UYVY.
33 */
34 OPENAVX_API void avx_color_rgba_to_uyvy(const uint8_t *src, uint8_t *dst, int width, int height);
35  
36 /**
37 * Converts 32-bit packed BGRA to packed 4:2:2 UYVY.
38 */
39 OPENAVX_API void avx_color_bgra_to_uyvy(const uint8_t *src, uint8_t *dst, int width, int height);
40  
41 /**
42 * In-place or copy conversion swapping Red and Blue channels (RGBA <-> BGRA).
43 */
44 OPENAVX_API void avx_color_rgba_to_bgra(const uint8_t *src, uint8_t *dst, int width, int height);
45  
46 /**
47 * Composites a transparent foreground RGBA image over a background RGBA image.
48 */
49 OPENAVX_API void avx_color_alpha_blend_rgba(const uint8_t *fg, const uint8_t *bg, uint8_t *out, int width, int height);
50  
51 /**
52 * Downconverts 16-bit P216 (semi-planar Y + interleaved UV) to packed 8-bit UYVY.
53 */
54 OPENAVX_API void avx_color_p216_to_uyvy(const uint8_t *src, uint8_t *dst, int width, int height);
55  
56 /**
57 * Upconverts packed 8-bit UYVY to 16-bit P216 (semi-planar Y + interleaved UV).
58 */
59 OPENAVX_API void avx_color_uyvy_to_p216(const uint8_t *src, uint8_t *dst, int width, int height);
60  
61 /**
62 * Converts 16-bit P216 (semi-planar Y + interleaved UV) to packed 32-bit RGBA.
63 */
64 OPENAVX_API void avx_color_p216_to_rgba(const uint8_t *src, uint8_t *dst, int width, int height);
65  
66 /**
67 * Converts packed 4:2:2 UYVY + separate 8-bit Alpha plane (UYVA) to 32-bit packed RGBA.
68 */
69 OPENAVX_API void avx_color_uyva_to_rgba(const uint8_t *uyvy, const uint8_t *alpha, uint8_t *dst, int width, int height);
70  
71 /**
72 * Converts packed 4:2:2 UYVY + separate 8-bit Alpha plane (UYVA) to 32-bit packed BGRA.
73 */
74 OPENAVX_API void avx_color_uyva_to_bgra(const uint8_t *uyvy, const uint8_t *alpha, uint8_t *dst, int width, int height);
75  
76 /**
77 * Converts 32-bit packed RGBA to packed 4:2:2 UYVY + separate 8-bit Alpha plane (UYVA).
78 */
79 OPENAVX_API void avx_color_rgba_to_uyva(const uint8_t *src, uint8_t *uyvy, uint8_t *alpha, int width, int height);
80  
81 /**
82 * Converts NV12 (semi-planar Y + interleaved UV 4:2:0) to packed 4:2:2 UYVY.
83 */
84 OPENAVX_API void avx_color_nv12_to_uyvy(const uint8_t *y_src, size_t y_stride,
85 const uint8_t *uv_src, size_t uv_stride,
86 uint8_t *dst, size_t dst_stride,
87 int width, int height);
88  
89 /**
90 * Converts NV12 (semi-planar Y + interleaved UV 4:2:0) to 32-bit packed RGBA.
91 */
92 OPENAVX_API void avx_color_nv12_to_rgba(const uint8_t *y_src, size_t y_stride,
93 const uint8_t *uv_src, size_t uv_stride,
94 uint8_t *dst, size_t dst_stride,
95 int width, int height);
96  
97 /**
98 * Converts NV12 (semi-planar Y + interleaved UV 4:2:0) to 32-bit packed BGRA.
99 */
100 OPENAVX_API void avx_color_nv12_to_bgra(const uint8_t *y_src, size_t y_stride,
101 const uint8_t *uv_src, size_t uv_stride,
102 uint8_t *dst, size_t dst_stride,
103 int width, int height);
104  
105 /**
106 * Converts I420 (planar Y + U + V 4:2:0) to packed 4:2:2 UYVY.
107 */
108 OPENAVX_API void avx_color_i420_to_uyvy(const uint8_t *y_src, size_t y_stride,
109 const uint8_t *u_src, size_t u_stride,
110 const uint8_t *v_src, size_t v_stride,
111 uint8_t *dst, size_t dst_stride,
112 int width, int height);
113  
114 /**
115 * Converts I420 (planar Y + U + V 4:2:0) to 32-bit packed RGBA.
116 */
117 OPENAVX_API void avx_color_i420_to_rgba(const uint8_t *y_src, size_t y_stride,
118 const uint8_t *u_src, size_t u_stride,
119 const uint8_t *v_src, size_t v_stride,
120 uint8_t *dst, size_t dst_stride,
121 int width, int height);
122  
123 /**
124 * Converts packed 4:2:2 UYVY to NV12 (semi-planar Y + interleaved UV 4:2:0).
125 */
126 OPENAVX_API void avx_color_uyvy_to_nv12(const uint8_t *src, size_t src_stride,
127 uint8_t *y_dst, size_t y_stride,
128 uint8_t *uv_dst, size_t uv_stride,
129 int width, int height);
130  
131 /**
132 * Converts packed 4:2:2 UYVY to I420 (planar Y + U + V 4:2:0).
133 */
134 OPENAVX_API void avx_color_uyvy_to_i420(const uint8_t *src, size_t src_stride,
135 uint8_t *y_dst, size_t y_stride,
136 uint8_t *u_dst, size_t u_stride,
137 uint8_t *v_dst, size_t v_stride,
138 int width, int height);
139  
140 /**
141 * Converts packed 4:2:2 UYVY to YV12 (planar Y + V + U 4:2:0).
142 */
143 OPENAVX_API void avx_color_uyvy_to_yv12(const uint8_t *src, size_t src_stride,
144 uint8_t *y_dst, size_t y_stride,
145 uint8_t *v_dst, size_t v_stride,
146 uint8_t *u_dst, size_t u_stride,
147 int width, int height);
148  
149 /**
150 * Converts YV12 (planar Y + V + U 4:2:0) to packed 4:2:2 UYVY.
151 */
152 OPENAVX_API void avx_color_yv12_to_uyvy(const uint8_t *y_src, size_t y_stride,
153 const uint8_t *v_src, size_t v_stride,
154 const uint8_t *u_src, size_t u_stride,
155 uint8_t *dst, size_t dst_stride,
156 int width, int height);
157  
158 /**
159 * Converts YV12 (planar Y + V + U 4:2:0) to 32-bit packed RGBA.
160 */
161 OPENAVX_API void avx_color_yv12_to_rgba(const uint8_t *y_src, size_t y_stride,
162 const uint8_t *v_src, size_t v_stride,
163 const uint8_t *u_src, size_t u_stride,
164 uint8_t *dst, size_t dst_stride,
165 int width, int height);
166  
167 /**
168 * Converts 32-bit packed RGBA directly to NV12 (semi-planar Y + interleaved UV 4:2:0).
169 */
170 OPENAVX_API void avx_color_rgba_to_nv12(const uint8_t *src, size_t src_stride,
171 uint8_t *y_dst, size_t y_stride,
172 uint8_t *uv_dst, size_t uv_stride,
173 int width, int height);
174  
175 /**
176 * Converts 32-bit packed RGBA directly to I420 (planar Y + U + V 4:2:0).
177 */
178 OPENAVX_API void avx_color_rgba_to_i420(const uint8_t *src, size_t src_stride,
179 uint8_t *y_dst, size_t y_stride,
180 uint8_t *u_dst, size_t u_stride,
181 uint8_t *v_dst, size_t v_stride,
182 int width, int height);
183  
184 /**
185 * Converts 32-bit packed RGBA directly to YV12 (planar Y + V + U 4:2:0).
186 */
187 OPENAVX_API void avx_color_rgba_to_yv12(const uint8_t *src, size_t src_stride,
188 uint8_t *y_dst, size_t y_stride,
189 uint8_t *v_dst, size_t v_stride,
190 uint8_t *u_dst, size_t u_stride,
191 int width, int height);
192  
193 #ifdef __cplusplus
194 }
195 #endif
196  
197 #endif /* AVX_COLOR_H */