22 #ifndef FREERDP_CODEC_PLANAR_H
23 #define FREERDP_CODEC_PLANAR_H
25 #include <winpr/cast.h>
26 #include <winpr/crt.h>
28 #include <freerdp/codec/color.h>
29 #include <freerdp/codec/bitmap.h>
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
41 static inline BYTE PLANAR_CONTROL_BYTE(UINT32 nRunLength, UINT32 cRawBytes)
43 return WINPR_ASSERTING_INT_CAST(UINT8, ((nRunLength & 0x0F) | ((cRawBytes & 0x0F) << 4)));
46 static inline BYTE PLANAR_CONTROL_BYTE_RUN_LENGTH(UINT32 controlByte)
48 return (controlByte & 0x0F);
50 static inline BYTE PLANAR_CONTROL_BYTE_RAW_BYTES(UINT32 controlByte)
52 return ((controlByte >> 4) & 0x0F);
55 typedef struct S_BITMAP_PLANAR_CONTEXT BITMAP_PLANAR_CONTEXT;
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);
63 FREERDP_API BOOL freerdp_bitmap_planar_context_reset(
64 BITMAP_PLANAR_CONTEXT* WINPR_RESTRICT context, UINT32 width, UINT32 height);
66 FREERDP_API
void freerdp_bitmap_planar_context_free(BITMAP_PLANAR_CONTEXT* context);
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,
72 FREERDP_API
void freerdp_planar_switch_bgr(BITMAP_PLANAR_CONTEXT* WINPR_RESTRICT planar,
74 FREERDP_API
void freerdp_planar_topdown_image(BITMAP_PLANAR_CONTEXT* WINPR_RESTRICT planar,
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);