FreeRDP
|
#include <winpr/assert.h>
#include <freerdp/config.h>
#include <freerdp/codec/interleaved.h>
#include <freerdp/log.h>
#include "include/bitmap.h"
Macros | |
#define | TAG FREERDP_TAG("codec") |
#define | UNROLL_BODY(_exp, _count) |
#define | UNROLL_MULTIPLE(_condition, _exp, _count) |
#define | UNROLL(_condition, _exp) |
#define | REGULAR_BG_RUN 0x00 |
#define | MEGA_MEGA_BG_RUN 0xF0 |
#define | REGULAR_FG_RUN 0x01 |
#define | MEGA_MEGA_FG_RUN 0xF1 |
#define | LITE_SET_FG_FG_RUN 0x0C |
#define | MEGA_MEGA_SET_FG_RUN 0xF6 |
#define | LITE_DITHERED_RUN 0x0E |
#define | MEGA_MEGA_DITHERED_RUN 0xF8 |
#define | REGULAR_COLOR_RUN 0x03 |
#define | MEGA_MEGA_COLOR_RUN 0xF3 |
#define | REGULAR_FGBG_IMAGE 0x02 |
#define | MEGA_MEGA_FGBG_IMAGE 0xF2 |
#define | LITE_SET_FG_FGBG_IMAGE 0x0D |
#define | MEGA_MEGA_SET_FGBG_IMAGE 0xF7 |
#define | REGULAR_COLOR_IMAGE 0x04 |
#define | MEGA_MEGA_COLOR_IMAGE 0xF4 |
#define | SPECIAL_FGBG_1 0xF9 |
#define | SPECIAL_FGBG_2 0xFA |
#define | SPECIAL_WHITE 0xFD |
#define | SPECIAL_BLACK 0xFE |
#define | BLACK_PIXEL 0x000000 |
#define | buffer_within_range(pbSrc, size, pbEnd) buffer_within_range_((pbSrc), (size), (pbEnd), __func__, __FILE__, __LINE__) |
#define | ensure_capacity(start, end, size, base) ensure_capacity_((start), (end), (size), (base), __func__, __FILE__, __LINE__) |
#define | PIXEL_SIZE 1 |
#define | PIXEL BYTE |
#define | WHITE_PIXEL 0xFF |
#define | DESTWRITEPIXEL(_buf, _pix) |
#define | DESTREADPIXEL(_pix, _buf) _pix = (_buf)[0] |
#define | SRCREADPIXEL(_pix, _buf) |
#define | WRITEFGBGIMAGE WriteFgBgImage8to8 |
#define | WRITEFIRSTLINEFGBGIMAGE WriteFirstLineFgBgImage8to8 |
#define | RLEDECOMPRESS RleDecompress8to8 |
#define | RLEEXTRA |
#define | ENSURE_CAPACITY(_start, _end, _size) ensure_capacity(_start, _end, _size, 1) |
#define | PIXEL_SIZE 2 |
#define | PIXEL UINT16 |
#define | WHITE_PIXEL 0xFFFF |
#define | DESTWRITEPIXEL(_buf, _pix) |
#define | DESTREADPIXEL(_pix, _buf) _pix = ((UINT16*)(_buf))[0] |
#define | SRCREADPIXEL(_pix, _buf) |
#define | WRITEFGBGIMAGE WriteFgBgImage16to16 |
#define | WRITEFIRSTLINEFGBGIMAGE WriteFirstLineFgBgImage16to16 |
#define | RLEDECOMPRESS RleDecompress16to16 |
#define | RLEEXTRA |
#define | ENSURE_CAPACITY(_start, _end, _size) ensure_capacity(_start, _end, _size, 2) |
#define | PIXEL_SIZE 3 |
#define | PIXEL UINT32 |
#define | WHITE_PIXEL 0xffffff |
#define | DESTWRITEPIXEL(_buf, _pix) |
#define | DESTREADPIXEL(_pix, _buf) _pix = (_buf)[0] | ((_buf)[1] << 8) | ((_buf)[2] << 16) |
#define | SRCREADPIXEL(_pix, _buf) |
#define | WRITEFGBGIMAGE WriteFgBgImage24to24 |
#define | WRITEFIRSTLINEFGBGIMAGE WriteFirstLineFgBgImage24to24 |
#define | RLEDECOMPRESS RleDecompress24to24 |
#define | RLEEXTRA |
#define | ENSURE_CAPACITY(_start, _end, _size) ensure_capacity(_start, _end, _size, 3) |
Typedefs | |
typedef UINT32 | PIXEL |
Functions | |
static const char * | rle_code_str (UINT32 code) |
static const char * | rle_code_str_buffer (UINT32 code, char *buffer, size_t size) |
static INLINE BOOL | buffer_within_range_ (const void *pbSrc, size_t size, const void *pbEnd, const char *fkt, const char *file, size_t line) |
static INLINE UINT32 | ExtractCodeId (BYTE bOrderHdr) |
static UINT | ExtractRunLengthRegularFgBg (const BYTE *pbOrderHdr, const BYTE *pbEnd, UINT32 *advance) |
static UINT | ExtractRunLengthLiteFgBg (const BYTE *pbOrderHdr, const BYTE *pbEnd, UINT32 *advance) |
static UINT | ExtractRunLengthRegular (const BYTE *pbOrderHdr, const BYTE *pbEnd, UINT32 *advance) |
static UINT | ExtractRunLengthMegaMega (const BYTE *pbOrderHdr, const BYTE *pbEnd, UINT32 *advance) |
static UINT | ExtractRunLengthLite (const BYTE *pbOrderHdr, const BYTE *pbEnd, UINT32 *advance) |
static INLINE UINT32 | ExtractRunLength (UINT32 code, const BYTE *pbOrderHdr, const BYTE *pbEnd, UINT32 *advance) |
static INLINE BOOL | ensure_capacity_ (const BYTE *start, const BYTE *end, size_t size, size_t base, const char *fkt, const char *file, size_t line) |
static INLINE void | write_pixel_8 (BYTE *_buf, BYTE _pix) |
static INLINE void | write_pixel_24 (BYTE *_buf, UINT32 _pix) |
static INLINE void | write_pixel_16 (BYTE *_buf, UINT16 _pix) |
BOOL | interleaved_decompress (BITMAP_INTERLEAVED_CONTEXT *WINPR_RESTRICT interleaved, const BYTE *WINPR_RESTRICT pSrcData, UINT32 SrcSize, UINT32 nSrcWidth, UINT32 nSrcHeight, UINT32 bpp, BYTE *WINPR_RESTRICT pDstData, UINT32 DstFormat, UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst, UINT32 nDstWidth, UINT32 nDstHeight, const gdiPalette *WINPR_RESTRICT palette) |
BOOL | interleaved_compress (BITMAP_INTERLEAVED_CONTEXT *WINPR_RESTRICT interleaved, BYTE *WINPR_RESTRICT pDstData, UINT32 *pDstSize, UINT32 nWidth, UINT32 nHeight, const BYTE *WINPR_RESTRICT pSrcData, UINT32 SrcFormat, UINT32 nSrcStep, UINT32 nXSrc, UINT32 nYSrc, const gdiPalette *WINPR_RESTRICT palette, UINT32 bpp) |
BOOL | bitmap_interleaved_context_reset (BITMAP_INTERLEAVED_CONTEXT *WINPR_RESTRICT interleaved) |
BITMAP_INTERLEAVED_CONTEXT * | bitmap_interleaved_context_new (BOOL Compressor) |
void | bitmap_interleaved_context_free (BITMAP_INTERLEAVED_CONTEXT *WINPR_RESTRICT interleaved) |
Variables | |
static const BYTE | g_MaskSpecialFgBg1 = 0x03 |
static const BYTE | g_MaskSpecialFgBg2 = 0x05 |
static const BYTE | g_MaskRegularRunLength = 0x1F |
static const BYTE | g_MaskLiteRunLength = 0x0F |
#define BLACK_PIXEL 0x000000 |
#define buffer_within_range | ( | pbSrc, | |
size, | |||
pbEnd | |||
) | buffer_within_range_((pbSrc), (size), (pbEnd), __func__, __FILE__, __LINE__) |
#define DESTREADPIXEL | ( | _pix, | |
_buf | |||
) | _pix = (_buf)[0] |
#define DESTREADPIXEL | ( | _pix, | |
_buf | |||
) | _pix = ((UINT16*)(_buf))[0] |
#define DESTREADPIXEL | ( | _pix, | |
_buf | |||
) | _pix = (_buf)[0] | ((_buf)[1] << 8) | ((_buf)[2] << 16) |
#define DESTWRITEPIXEL | ( | _buf, | |
_pix | |||
) |
#define DESTWRITEPIXEL | ( | _buf, | |
_pix | |||
) |
#define DESTWRITEPIXEL | ( | _buf, | |
_pix | |||
) |
#define ENSURE_CAPACITY | ( | _start, | |
_end, | |||
_size | |||
) | ensure_capacity(_start, _end, _size, 1) |
#define ENSURE_CAPACITY | ( | _start, | |
_end, | |||
_size | |||
) | ensure_capacity(_start, _end, _size, 2) |
#define ENSURE_CAPACITY | ( | _start, | |
_end, | |||
_size | |||
) | ensure_capacity(_start, _end, _size, 3) |
#define ensure_capacity | ( | start, | |
end, | |||
size, | |||
base | |||
) | ensure_capacity_((start), (end), (size), (base), __func__, __FILE__, __LINE__) |
#define LITE_DITHERED_RUN 0x0E |
#define LITE_SET_FG_FG_RUN 0x0C |
#define LITE_SET_FG_FGBG_IMAGE 0x0D |
#define MEGA_MEGA_BG_RUN 0xF0 |
#define MEGA_MEGA_COLOR_IMAGE 0xF4 |
#define MEGA_MEGA_COLOR_RUN 0xF3 |
#define MEGA_MEGA_DITHERED_RUN 0xF8 |
#define MEGA_MEGA_FG_RUN 0xF1 |
#define MEGA_MEGA_FGBG_IMAGE 0xF2 |
#define MEGA_MEGA_SET_FG_RUN 0xF6 |
#define MEGA_MEGA_SET_FGBG_IMAGE 0xF7 |
#define PIXEL UINT32 |
#define PIXEL_SIZE 1 |
#define PIXEL_SIZE 2 |
#define PIXEL_SIZE 3 |
#define REGULAR_BG_RUN 0x00 |
#define REGULAR_COLOR_IMAGE 0x04 |
#define REGULAR_COLOR_RUN 0x03 |
#define REGULAR_FG_RUN 0x01 |
#define REGULAR_FGBG_IMAGE 0x02 |
#define RLEDECOMPRESS RleDecompress8to8 |
#define RLEDECOMPRESS RleDecompress16to16 |
#define RLEDECOMPRESS RleDecompress24to24 |
#define RLEEXTRA |
#define RLEEXTRA |
#define RLEEXTRA |
#define SPECIAL_BLACK 0xFE |
#define SPECIAL_FGBG_1 0xF9 |
#define SPECIAL_FGBG_2 0xFA |
#define SPECIAL_WHITE 0xFD |
#define SRCREADPIXEL | ( | _pix, | |
_buf | |||
) |
#define SRCREADPIXEL | ( | _pix, | |
_buf | |||
) |
#define SRCREADPIXEL | ( | _pix, | |
_buf | |||
) |
#define TAG FREERDP_TAG("codec") |
FreeRDP: A Remote Desktop Protocol Implementation Interleaved RLE Bitmap Codec
Copyright 2014 Marc-Andre Moreau marca Copyright 2015 Thincast Technologies GmbH Copyright 2015 DI (FH) Martin Haimberger ndre .more au@g mail. commarti Copyright 2016 Armin Novak n.ha imber ger@ thinc ast. comarmin Copyright 2016 Thincast Technologies GmbH .nov ak@th inca st.co m
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
#define UNROLL | ( | _condition, | |
_exp | |||
) |
#define UNROLL_BODY | ( | _exp, | |
_count | |||
) |
#define UNROLL_MULTIPLE | ( | _condition, | |
_exp, | |||
_count | |||
) |
#define WHITE_PIXEL 0xFF |
#define WHITE_PIXEL 0xFFFF |
#define WHITE_PIXEL 0xffffff |
#define WRITEFGBGIMAGE WriteFgBgImage8to8 |
#define WRITEFGBGIMAGE WriteFgBgImage16to16 |
#define WRITEFGBGIMAGE WriteFgBgImage24to24 |
#define WRITEFIRSTLINEFGBGIMAGE WriteFirstLineFgBgImage8to8 |
#define WRITEFIRSTLINEFGBGIMAGE WriteFirstLineFgBgImage16to16 |
#define WRITEFIRSTLINEFGBGIMAGE WriteFirstLineFgBgImage24to24 |
typedef UINT32 PIXEL |
void bitmap_interleaved_context_free | ( | BITMAP_INTERLEAVED_CONTEXT *WINPR_RESTRICT | interleaved | ) |
BITMAP_INTERLEAVED_CONTEXT* bitmap_interleaved_context_new | ( | BOOL | Compressor | ) |
BOOL bitmap_interleaved_context_reset | ( | BITMAP_INTERLEAVED_CONTEXT *WINPR_RESTRICT | interleaved | ) |
|
static |
|
static |
Reads the supplied order header and extracts the compression order code ID.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Extract the run length of a compression order.
BOOL interleaved_compress | ( | BITMAP_INTERLEAVED_CONTEXT *WINPR_RESTRICT | interleaved, |
BYTE *WINPR_RESTRICT | pDstData, | ||
UINT32 * | pDstSize, | ||
UINT32 | nWidth, | ||
UINT32 | nHeight, | ||
const BYTE *WINPR_RESTRICT | pSrcData, | ||
UINT32 | SrcFormat, | ||
UINT32 | nSrcStep, | ||
UINT32 | nXSrc, | ||
UINT32 | nYSrc, | ||
const gdiPalette *WINPR_RESTRICT | palette, | ||
UINT32 | bpp | ||
) |
BOOL interleaved_decompress | ( | BITMAP_INTERLEAVED_CONTEXT *WINPR_RESTRICT | interleaved, |
const BYTE *WINPR_RESTRICT | pSrcData, | ||
UINT32 | SrcSize, | ||
UINT32 | nSrcWidth, | ||
UINT32 | nSrcHeight, | ||
UINT32 | bpp, | ||
BYTE *WINPR_RESTRICT | pDstData, | ||
UINT32 | DstFormat, | ||
UINT32 | nDstStep, | ||
UINT32 | nXDst, | ||
UINT32 | nYDst, | ||
UINT32 | nDstWidth, | ||
UINT32 | nDstHeight, | ||
const gdiPalette *WINPR_RESTRICT | palette | ||
) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |