FreeRDP
Loading...
Searching...
No Matches
image_ffmpeg.h
1
20#ifndef FREERDP_LIB_CODEC_IMAGE_FFMPEG_H
21#define FREERDP_LIB_CODEC_IMAGE_FFMPEG_H
22
23#include <winpr/wtypes.h>
24#include <freerdp/config.h>
25
26#if defined(WITH_SWSCALE)
27
28#if defined(WITH_SWSCALE_LOADING)
29
30#include <stdint.h>
31
32/* Forward declarations to avoid requiring swscale headers at compile time */
33struct SwsContext;
34
35/* AVPixelFormat enum values we need (from libavutil/pixfmt.h).
36 * Define only what we use to avoid requiring FFmpeg headers at build time. */
37enum AVPixelFormat
38{
39 AV_PIX_FMT_NONE = -1,
40 AV_PIX_FMT_YUV420P = 0,
41 AV_PIX_FMT_YUYV422 = 1,
42 AV_PIX_FMT_RGB24 = 2,
43 AV_PIX_FMT_BGR24 = 3,
44 AV_PIX_FMT_YUV422P = 4,
45 AV_PIX_FMT_YUV444P = 5,
46 AV_PIX_FMT_YUV410P = 6,
47 AV_PIX_FMT_YUV411P = 7,
48 AV_PIX_FMT_GRAY8 = 8,
49 AV_PIX_FMT_MONOWHITE = 9,
50 AV_PIX_FMT_MONOBLACK = 10,
51 AV_PIX_FMT_PAL8 = 11,
52 AV_PIX_FMT_YUVJ420P = 12,
53 AV_PIX_FMT_YUVJ422P = 13,
54 AV_PIX_FMT_YUVJ444P = 14,
55 AV_PIX_FMT_UYVY422 = 15,
56 AV_PIX_FMT_UYYVYY411 = 16,
57 AV_PIX_FMT_BGR8 = 17,
58 AV_PIX_FMT_BGR4 = 18,
59 AV_PIX_FMT_BGR4_BYTE = 19,
60 AV_PIX_FMT_RGB8 = 20,
61 AV_PIX_FMT_RGB4 = 21,
62 AV_PIX_FMT_RGB4_BYTE = 22,
63 AV_PIX_FMT_NV12 = 23,
64 AV_PIX_FMT_NV21 = 24,
65 AV_PIX_FMT_ARGB = 25,
66 AV_PIX_FMT_RGBA = 26,
67 AV_PIX_FMT_ABGR = 27,
68 AV_PIX_FMT_BGRA = 28,
69 AV_PIX_FMT_GRAY16BE = 29,
70 AV_PIX_FMT_GRAY16LE = 30,
71 AV_PIX_FMT_YUV440P = 31,
72 AV_PIX_FMT_YUVJ440P = 32,
73 AV_PIX_FMT_YUVA420P = 33,
74 AV_PIX_FMT_RGB48BE = 34,
75 AV_PIX_FMT_RGB48LE = 35,
76 AV_PIX_FMT_RGB565BE = 36,
77 AV_PIX_FMT_RGB565LE = 37,
78 AV_PIX_FMT_RGB555BE = 38,
79 AV_PIX_FMT_RGB555LE = 39,
80 AV_PIX_FMT_BGR565BE = 40,
81 AV_PIX_FMT_BGR565LE = 41,
82 AV_PIX_FMT_BGR555BE = 42,
83 AV_PIX_FMT_BGR555LE = 43,
84 AV_PIX_FMT_YUVJ411P = 44,
85 /* Specific ones used in color.c */
86 AV_PIX_FMT_RGB0 = 123,
87 AV_PIX_FMT_BGR0 = 124
88};
89
90/* FFmpeg compatibility macros for deprecated RGB32/BGR32 formats.
91 * These map to different formats based on endianness. */
92#if defined(__BIG_ENDIAN__) || (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
93#define AV_PIX_FMT_RGB32 AV_PIX_FMT_ARGB
94#define AV_PIX_FMT_BGR32 AV_PIX_FMT_ABGR
95#else
96#define AV_PIX_FMT_RGB32 AV_PIX_FMT_BGRA
97#define AV_PIX_FMT_BGR32 AV_PIX_FMT_RGBA
98#endif
99
100/* swscale algorithm flags (from libswscale/swscale.h) */
101#define SWS_FAST_BILINEAR 1
102#define SWS_BILINEAR 2
103#define SWS_BICUBIC 4
104#define SWS_X 8
105#define SWS_POINT 0x10
106#define SWS_AREA 0x20
107#define SWS_BICUBLIN 0x40
108#define SWS_GAUSS 0x80
109#define SWS_SINC 0x100
110#define SWS_LANCZOS 0x200
111#define SWS_SPLINE 0x400
112
113#ifdef __cplusplus
114extern "C"
115{
116#endif
117
122 BOOL freerdp_swscale_init(void);
123
128 BOOL freerdp_swscale_available(void);
129
133 struct SwsContext* freerdp_sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH,
134 int dstFormat, int flags, void* srcFilter,
135 void* dstFilter, const double* param);
136
140 int freerdp_sws_scale(struct SwsContext* ctx, const uint8_t* const srcSlice[],
141 const int srcStride[], int srcSliceY, int srcSliceH, uint8_t* const dst[],
142 const int dstStride[]);
143
147 void freerdp_sws_freeContext(struct SwsContext* ctx);
148
153 BOOL freerdp_avutil_init(void);
154
159 BOOL freerdp_avutil_available(void);
160
164 int freerdp_av_image_fill_linesizes(int linesizes[4], int pix_fmt, int width);
165
169 int freerdp_av_image_fill_pointers(uint8_t* data[4], int pix_fmt, int height, uint8_t* ptr,
170 const int linesizes[4]);
171
172#ifdef __cplusplus
173}
174#endif
175
176#else /* !WITH_SWSCALE_LOADING */
177
178#include <libswscale/swscale.h>
179#include <libavutil/pixfmt.h>
180#include <libavutil/imgutils.h>
181
182#ifdef __cplusplus
183extern "C"
184{
185#endif
186
187 static inline BOOL freerdp_swscale_init(void)
188 {
189 return TRUE;
190 }
191
192 static inline BOOL freerdp_swscale_available(void)
193 {
194 return TRUE;
195 }
196
197 static inline struct SwsContext* freerdp_sws_getContext(int srcW, int srcH, int srcFormat,
198 int dstW, int dstH, int dstFormat,
199 int flags, void* srcFilter,
200 void* dstFilter, const double* param)
201 {
202 return sws_getContext(srcW, srcH, (enum AVPixelFormat)srcFormat, dstW, dstH,
203 (enum AVPixelFormat)dstFormat, flags, (SwsFilter*)srcFilter,
204 (SwsFilter*)dstFilter, param);
205 }
206
207 static inline int freerdp_sws_scale(struct SwsContext* ctx, const uint8_t* const srcSlice[],
208 const int srcStride[], int srcSliceY, int srcSliceH,
209 uint8_t* const dst[], const int dstStride[])
210 {
211 return sws_scale(ctx, srcSlice, srcStride, srcSliceY, srcSliceH, dst, dstStride);
212 }
213
214 static inline void freerdp_sws_freeContext(struct SwsContext* ctx)
215 {
216 sws_freeContext(ctx);
217 }
218
219 static inline BOOL freerdp_avutil_init(void)
220 {
221 return TRUE;
222 }
223
224 static inline BOOL freerdp_avutil_available(void)
225 {
226 return TRUE;
227 }
228
229 static inline int freerdp_av_image_fill_linesizes(int linesizes[4], int pix_fmt, int width)
230 {
231 return av_image_fill_linesizes(linesizes, (enum AVPixelFormat)pix_fmt, width);
232 }
233
234 static inline int freerdp_av_image_fill_pointers(uint8_t* data[4], int pix_fmt, int height,
235 uint8_t* ptr, const int linesizes[4])
236 {
237 return av_image_fill_pointers(data, (enum AVPixelFormat)pix_fmt, height, ptr, linesizes);
238 }
239
240#ifdef __cplusplus
241}
242#endif
243
244#endif /* WITH_SWSCALE_LOADING */
245
246#endif /* WITH_SWSCALE */
247
248#endif /* FREERDP_LIB_CODEC_IMAGE_FFMPEG_H */