FreeRDP
Loading...
Searching...
No Matches
planar.h
1
22#ifndef FREERDP_CODEC_PLANAR_H
23#define FREERDP_CODEC_PLANAR_H
24
25#include <winpr/cast.h>
26#include <winpr/crt.h>
27
28#include <freerdp/codec/color.h>
29#include <freerdp/codec/bitmap.h>
30
31#define PLANAR_FORMAT_HEADER_CS (1 << 3)
32#define PLANAR_FORMAT_HEADER_RLE (1 << 4)
33#define PLANAR_FORMAT_HEADER_NA (1 << 5)
34#define PLANAR_FORMAT_HEADER_CLL_MASK 0x07
35
36#ifdef __cplusplus
37extern "C"
38{
39#endif
40
41 static inline BYTE PLANAR_CONTROL_BYTE(UINT32 nRunLength, UINT32 cRawBytes)
42 {
43 return WINPR_ASSERTING_INT_CAST(UINT8, ((nRunLength & 0x0F) | ((cRawBytes & 0x0F) << 4)));
44 }
45
46 static inline BYTE PLANAR_CONTROL_BYTE_RUN_LENGTH(UINT32 controlByte)
47 {
48 return (controlByte & 0x0F);
49 }
50 static inline BYTE PLANAR_CONTROL_BYTE_RAW_BYTES(UINT32 controlByte)
51 {
52 return ((controlByte >> 4) & 0x0F);
53 }
54
55 typedef struct S_BITMAP_PLANAR_CONTEXT BITMAP_PLANAR_CONTEXT;
56
57 FREERDP_API BYTE* freerdp_bitmap_compress_planar(BITMAP_PLANAR_CONTEXT* WINPR_RESTRICT context,
58 const BYTE* WINPR_RESTRICT data, UINT32 format,
59 UINT32 width, UINT32 height, UINT32 scanline,
60 BYTE* WINPR_RESTRICT dstData,
61 UINT32* WINPR_RESTRICT pDstSize);
62
63 FREERDP_API BOOL freerdp_bitmap_planar_context_reset(
64 BITMAP_PLANAR_CONTEXT* WINPR_RESTRICT context, UINT32 width, UINT32 height);
65
66 FREERDP_API void freerdp_bitmap_planar_context_free(BITMAP_PLANAR_CONTEXT* context);
67
68 WINPR_ATTR_MALLOC(freerdp_bitmap_planar_context_free, 1)
69 FREERDP_API BITMAP_PLANAR_CONTEXT* freerdp_bitmap_planar_context_new(DWORD flags, UINT32 width,
70 UINT32 height);
71
72 FREERDP_API void freerdp_planar_switch_bgr(BITMAP_PLANAR_CONTEXT* WINPR_RESTRICT planar,
73 BOOL bgr);
74 FREERDP_API void freerdp_planar_topdown_image(BITMAP_PLANAR_CONTEXT* WINPR_RESTRICT planar,
75 BOOL topdown);
76
77 FREERDP_API BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* WINPR_RESTRICT planar,
78 const BYTE* WINPR_RESTRICT pSrcData, UINT32 SrcSize,
79 UINT32 nSrcWidth, UINT32 nSrcHeight,
80 BYTE* WINPR_RESTRICT pDstData, UINT32 DstFormat,
81 UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
82 UINT32 nDstWidth, UINT32 nDstHeight, BOOL vFlip);
83
84#ifdef __cplusplus
85}
86#endif
87
88#endif /* FREERDP_CODEC_PLANAR_H */