cscg24-guacamole

CSCG 2024 Challenge 'Guacamole Mashup'
git clone https://git.sinitax.com/sinitax/cscg24-guacamole
Log | Files | Refs | sfeed.txt

planar.h (3885B)


      1/**
      2 * FreeRDP: A Remote Desktop Protocol Implementation
      3 * RDP6 Planar Codec
      4 *
      5 * Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
      6 * Copyright 2016 Armin Novak <armin.novak@thincast.com>
      7 * Copyright 2016 Thincast Technologies GmbH
      8 *
      9 * Licensed under the Apache License, Version 2.0 (the "License");
     10 * you may not use this file except in compliance with the License.
     11 * You may obtain a copy of the License at
     12 *
     13 *     http://www.apache.org/licenses/LICENSE-2.0
     14 *
     15 * Unless required by applicable law or agreed to in writing, software
     16 * distributed under the License is distributed on an "AS IS" BASIS,
     17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     18 * See the License for the specific language governing permissions and
     19 * limitations under the License.
     20 */
     21
     22#ifndef FREERDP_CODEC_PLANAR_H
     23#define FREERDP_CODEC_PLANAR_H
     24
     25#include <winpr/crt.h>
     26
     27typedef struct _BITMAP_PLANAR_CONTEXT BITMAP_PLANAR_CONTEXT;
     28
     29#include <freerdp/codec/color.h>
     30#include <freerdp/codec/bitmap.h>
     31
     32#define PLANAR_FORMAT_HEADER_CS (1 << 3)
     33#define PLANAR_FORMAT_HEADER_RLE (1 << 4)
     34#define PLANAR_FORMAT_HEADER_NA (1 << 5)
     35#define PLANAR_FORMAT_HEADER_CLL_MASK 0x07
     36
     37#define PLANAR_CONTROL_BYTE(_nRunLength, _cRawBytes) \
     38	(_nRunLength & 0x0F) | ((_cRawBytes & 0x0F) << 4)
     39
     40#define PLANAR_CONTROL_BYTE_RUN_LENGTH(_controlByte) (_controlByte & 0x0F)
     41#define PLANAR_CONTROL_BYTE_RAW_BYTES(_controlByte) ((_controlByte >> 4) & 0x0F)
     42
     43struct _RDP6_RLE_SEGMENT
     44{
     45	/**
     46	 * controlByte:
     47	 * [0-3]: nRunLength
     48	 * [4-7]: cRawBytes
     49	 */
     50	BYTE controlByte;
     51	BYTE* rawValues;
     52};
     53typedef struct _RDP6_RLE_SEGMENT RDP6_RLE_SEGMENT;
     54
     55struct _RDP6_RLE_SEGMENTS
     56{
     57	UINT32 cSegments;
     58	RDP6_RLE_SEGMENT* segments;
     59};
     60typedef struct _RDP6_RLE_SEGMENTS RDP6_RLE_SEGMENTS;
     61
     62struct _RDP6_BITMAP_STREAM
     63{
     64	/**
     65	 * formatHeader:
     66	 * [0-2]: Color Loss Level (CLL)
     67	 *  [3] : Chroma Subsampling (CS)
     68	 *  [4] : Run Length Encoding (RLE)
     69	 *  [5] : No Alpha (NA)
     70	 * [6-7]: Reserved
     71	 */
     72	BYTE formatHeader;
     73};
     74typedef struct _RDP6_BITMAP_STREAM RDP6_BITMAP_STREAM;
     75
     76struct _BITMAP_PLANAR_CONTEXT
     77{
     78	UINT32 maxWidth;
     79	UINT32 maxHeight;
     80	UINT32 maxPlaneSize;
     81
     82	BOOL AllowSkipAlpha;
     83	BOOL AllowRunLengthEncoding;
     84	BOOL AllowColorSubsampling;
     85	BOOL AllowDynamicColorFidelity;
     86
     87	UINT32 ColorLossLevel;
     88
     89	BYTE* planes[4];
     90	BYTE* planesBuffer;
     91
     92	BYTE* deltaPlanes[4];
     93	BYTE* deltaPlanesBuffer;
     94
     95	BYTE* rlePlanes[4];
     96	BYTE* rlePlanesBuffer;
     97
     98	BYTE* pTempData;
     99	UINT32 nTempStep;
    100
    101	BOOL bgr;
    102};
    103
    104#ifdef __cplusplus
    105extern "C"
    106{
    107#endif
    108
    109	FREERDP_API BYTE* freerdp_bitmap_compress_planar(BITMAP_PLANAR_CONTEXT* context,
    110	                                                 const BYTE* data, UINT32 format, UINT32 width,
    111	                                                 UINT32 height, UINT32 scanline, BYTE* dstData,
    112	                                                 UINT32* pDstSize);
    113
    114	FREERDP_API BOOL freerdp_bitmap_planar_context_reset(BITMAP_PLANAR_CONTEXT* context,
    115	                                                     UINT32 width, UINT32 height);
    116
    117	FREERDP_API BITMAP_PLANAR_CONTEXT* freerdp_bitmap_planar_context_new(DWORD flags, UINT32 width,
    118	                                                                     UINT32 height);
    119	FREERDP_API void freerdp_bitmap_planar_context_free(BITMAP_PLANAR_CONTEXT* context);
    120
    121	FREERDP_API void freerdp_planar_switch_bgr(BITMAP_PLANAR_CONTEXT* planar, BOOL bgr);
    122
    123	FREERDP_API BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar, const BYTE* pSrcData,
    124	                                   UINT32 SrcSize, UINT32 nSrcWidth, UINT32 nSrcHeight,
    125	                                   BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStep,
    126	                                   UINT32 nXDst, UINT32 nYDst, UINT32 nDstWidth,
    127	                                   UINT32 nDstHeight, BOOL vFlip);
    128
    129#ifdef __cplusplus
    130}
    131#endif
    132
    133#endif /* FREERDP_CODEC_PLANAR_H */