FreeRDP
interleaved.c File Reference
#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
 

Macro Definition Documentation

◆ BLACK_PIXEL

#define BLACK_PIXEL   0x000000

◆ buffer_within_range

#define buffer_within_range (   pbSrc,
  size,
  pbEnd 
)     buffer_within_range_((pbSrc), (size), (pbEnd), __func__, __FILE__, __LINE__)

◆ DESTREADPIXEL [1/3]

#define DESTREADPIXEL (   _pix,
  _buf 
)    _pix = (_buf)[0]

◆ DESTREADPIXEL [2/3]

#define DESTREADPIXEL (   _pix,
  _buf 
)    _pix = ((UINT16*)(_buf))[0]

◆ DESTREADPIXEL [3/3]

#define DESTREADPIXEL (   _pix,
  _buf 
)    _pix = (_buf)[0] | ((_buf)[1] << 8) | ((_buf)[2] << 16)

◆ DESTWRITEPIXEL [1/3]

#define DESTWRITEPIXEL (   _buf,
  _pix 
)
Value:
do \
{ \
write_pixel_8(_buf, _pix); \
(_buf) += 1; \
} while (0)

◆ DESTWRITEPIXEL [2/3]

#define DESTWRITEPIXEL (   _buf,
  _pix 
)
Value:
do \
{ \
write_pixel_16(_buf, _pix); \
(_buf) += 2; \
} while (0)

◆ DESTWRITEPIXEL [3/3]

#define DESTWRITEPIXEL (   _buf,
  _pix 
)
Value:
do \
{ \
write_pixel_24(_buf, _pix); \
(_buf) += 3; \
} while (0)

◆ ENSURE_CAPACITY [1/3]

#define ENSURE_CAPACITY (   _start,
  _end,
  _size 
)    ensure_capacity(_start, _end, _size, 1)

◆ ENSURE_CAPACITY [2/3]

#define ENSURE_CAPACITY (   _start,
  _end,
  _size 
)    ensure_capacity(_start, _end, _size, 2)

◆ ENSURE_CAPACITY [3/3]

#define ENSURE_CAPACITY (   _start,
  _end,
  _size 
)    ensure_capacity(_start, _end, _size, 3)

◆ ensure_capacity

#define ensure_capacity (   start,
  end,
  size,
  base 
)     ensure_capacity_((start), (end), (size), (base), __func__, __FILE__, __LINE__)

◆ LITE_DITHERED_RUN

#define LITE_DITHERED_RUN   0x0E

◆ LITE_SET_FG_FG_RUN

#define LITE_SET_FG_FG_RUN   0x0C

◆ LITE_SET_FG_FGBG_IMAGE

#define LITE_SET_FG_FGBG_IMAGE   0x0D

◆ MEGA_MEGA_BG_RUN

#define MEGA_MEGA_BG_RUN   0xF0

◆ MEGA_MEGA_COLOR_IMAGE

#define MEGA_MEGA_COLOR_IMAGE   0xF4

◆ MEGA_MEGA_COLOR_RUN

#define MEGA_MEGA_COLOR_RUN   0xF3

◆ MEGA_MEGA_DITHERED_RUN

#define MEGA_MEGA_DITHERED_RUN   0xF8

◆ MEGA_MEGA_FG_RUN

#define MEGA_MEGA_FG_RUN   0xF1

◆ MEGA_MEGA_FGBG_IMAGE

#define MEGA_MEGA_FGBG_IMAGE   0xF2

◆ MEGA_MEGA_SET_FG_RUN

#define MEGA_MEGA_SET_FG_RUN   0xF6

◆ MEGA_MEGA_SET_FGBG_IMAGE

#define MEGA_MEGA_SET_FGBG_IMAGE   0xF7

◆ PIXEL [1/3]

#define PIXEL   BYTE

◆ PIXEL [2/3]

#define PIXEL   UINT16

◆ PIXEL [3/3]

#define PIXEL   UINT32

◆ PIXEL_SIZE [1/3]

#define PIXEL_SIZE   1

◆ PIXEL_SIZE [2/3]

#define PIXEL_SIZE   2

◆ PIXEL_SIZE [3/3]

#define PIXEL_SIZE   3

◆ REGULAR_BG_RUN

#define REGULAR_BG_RUN   0x00

◆ REGULAR_COLOR_IMAGE

#define REGULAR_COLOR_IMAGE   0x04

◆ REGULAR_COLOR_RUN

#define REGULAR_COLOR_RUN   0x03

◆ REGULAR_FG_RUN

#define REGULAR_FG_RUN   0x01

◆ REGULAR_FGBG_IMAGE

#define REGULAR_FGBG_IMAGE   0x02

◆ RLEDECOMPRESS [1/3]

#define RLEDECOMPRESS   RleDecompress8to8

◆ RLEDECOMPRESS [2/3]

#define RLEDECOMPRESS   RleDecompress16to16

◆ RLEDECOMPRESS [3/3]

#define RLEDECOMPRESS   RleDecompress24to24

◆ RLEEXTRA [1/3]

#define RLEEXTRA

◆ RLEEXTRA [2/3]

#define RLEEXTRA

◆ RLEEXTRA [3/3]

#define RLEEXTRA

◆ SPECIAL_BLACK

#define SPECIAL_BLACK   0xFE

◆ SPECIAL_FGBG_1

#define SPECIAL_FGBG_1   0xF9

◆ SPECIAL_FGBG_2

#define SPECIAL_FGBG_2   0xFA

◆ SPECIAL_WHITE

#define SPECIAL_WHITE   0xFD

◆ SRCREADPIXEL [1/3]

#define SRCREADPIXEL (   _pix,
  _buf 
)
Value:
do \
{ \
(_pix) = (_buf)[0]; \
(_buf) += 1; \
} while (0)

◆ SRCREADPIXEL [2/3]

#define SRCREADPIXEL (   _pix,
  _buf 
)
Value:
do \
{ \
(_pix) = (_buf)[0] | ((_buf)[1] << 8); \
(_buf) += 2; \
} while (0)

◆ SRCREADPIXEL [3/3]

#define SRCREADPIXEL (   _pix,
  _buf 
)
Value:
do \
{ \
(_pix) = (_buf)[0] | ((_buf)[1] << 8) | ((_buf)[2] << 16); \
(_buf) += 3; \
} while (0)

◆ TAG

#define TAG   FREERDP_TAG("codec")

FreeRDP: A Remote Desktop Protocol Implementation Interleaved RLE Bitmap Codec

Copyright 2014 Marc-Andre Moreau marca.nosp@m.ndre.nosp@m..more.nosp@m.au@g.nosp@m.mail..nosp@m.com Copyright 2015 Thincast Technologies GmbH Copyright 2015 DI (FH) Martin Haimberger marti.nosp@m.n.ha.nosp@m.imber.nosp@m.ger@.nosp@m.thinc.nosp@m.ast..nosp@m.com Copyright 2016 Armin Novak armin.nosp@m..nov.nosp@m.ak@th.nosp@m.inca.nosp@m.st.co.nosp@m.m Copyright 2016 Thincast Technologies GmbH

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.

◆ UNROLL

#define UNROLL (   _condition,
  _exp 
)
Value:
do \
{ \
UNROLL_MULTIPLE(_condition, _exp, 16); \
UNROLL_MULTIPLE(_condition, _exp, 4); \
UNROLL_MULTIPLE(_condition, _exp, 1); \
} while (FALSE)

◆ UNROLL_BODY

#define UNROLL_BODY (   _exp,
  _count 
)
Value:
do \
{ \
for (size_t x = 0; x < (_count); x++) \
{ \
do \
{ \
_exp \
} while (FALSE); \
} \
} while (FALSE)
UINT16 x
Definition: include/freerdp/event.h:110

◆ UNROLL_MULTIPLE

#define UNROLL_MULTIPLE (   _condition,
  _exp,
  _count 
)
Value:
do \
{ \
while ((_condition) >= (_count)) \
{ \
UNROLL_BODY(_exp, _count); \
(_condition) -= (_count); \
} \
} while (FALSE)

◆ WHITE_PIXEL [1/3]

#define WHITE_PIXEL   0xFF

◆ WHITE_PIXEL [2/3]

#define WHITE_PIXEL   0xFFFF

◆ WHITE_PIXEL [3/3]

#define WHITE_PIXEL   0xffffff

◆ WRITEFGBGIMAGE [1/3]

#define WRITEFGBGIMAGE   WriteFgBgImage8to8

◆ WRITEFGBGIMAGE [2/3]

#define WRITEFGBGIMAGE   WriteFgBgImage16to16

◆ WRITEFGBGIMAGE [3/3]

#define WRITEFGBGIMAGE   WriteFgBgImage24to24

◆ WRITEFIRSTLINEFGBGIMAGE [1/3]

#define WRITEFIRSTLINEFGBGIMAGE   WriteFirstLineFgBgImage8to8

◆ WRITEFIRSTLINEFGBGIMAGE [2/3]

#define WRITEFIRSTLINEFGBGIMAGE   WriteFirstLineFgBgImage16to16

◆ WRITEFIRSTLINEFGBGIMAGE [3/3]

#define WRITEFIRSTLINEFGBGIMAGE   WriteFirstLineFgBgImage24to24

Typedef Documentation

◆ PIXEL

typedef UINT32 PIXEL

Function Documentation

◆ bitmap_interleaved_context_free()

void bitmap_interleaved_context_free ( BITMAP_INTERLEAVED_CONTEXT *WINPR_RESTRICT  interleaved)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bitmap_interleaved_context_new()

BITMAP_INTERLEAVED_CONTEXT* bitmap_interleaved_context_new ( BOOL  Compressor)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bitmap_interleaved_context_reset()

BOOL bitmap_interleaved_context_reset ( BITMAP_INTERLEAVED_CONTEXT *WINPR_RESTRICT  interleaved)
Here is the caller graph for this function:

◆ buffer_within_range_()

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

◆ ensure_capacity_()

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

◆ ExtractCodeId()

static INLINE UINT32 ExtractCodeId ( BYTE  bOrderHdr)
static

Reads the supplied order header and extracts the compression order code ID.

Here is the caller graph for this function:

◆ ExtractRunLength()

static INLINE UINT32 ExtractRunLength ( UINT32  code,
const BYTE pbOrderHdr,
const BYTE pbEnd,
UINT32 *  advance 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExtractRunLengthLite()

static UINT ExtractRunLengthLite ( const BYTE pbOrderHdr,
const BYTE pbEnd,
UINT32 *  advance 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExtractRunLengthLiteFgBg()

static UINT ExtractRunLengthLiteFgBg ( const BYTE pbOrderHdr,
const BYTE pbEnd,
UINT32 *  advance 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExtractRunLengthMegaMega()

static UINT ExtractRunLengthMegaMega ( const BYTE pbOrderHdr,
const BYTE pbEnd,
UINT32 *  advance 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExtractRunLengthRegular()

static UINT ExtractRunLengthRegular ( const BYTE pbOrderHdr,
const BYTE pbEnd,
UINT32 *  advance 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExtractRunLengthRegularFgBg()

static UINT ExtractRunLengthRegularFgBg ( const BYTE pbOrderHdr,
const BYTE pbEnd,
UINT32 *  advance 
)
static

Extract the run length of a compression order.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ interleaved_compress()

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 
)
Here is the call graph for this function:

◆ interleaved_decompress()

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 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rle_code_str()

static const char* rle_code_str ( UINT32  code)
static
Here is the caller graph for this function:

◆ rle_code_str_buffer()

static const char* rle_code_str_buffer ( UINT32  code,
char *  buffer,
size_t  size 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_pixel_16()

static INLINE void write_pixel_16 ( BYTE _buf,
UINT16  _pix 
)
static

◆ write_pixel_24()

static INLINE void write_pixel_24 ( BYTE _buf,
UINT32  _pix 
)
static

◆ write_pixel_8()

static INLINE void write_pixel_8 ( BYTE _buf,
BYTE  _pix 
)
static

Variable Documentation

◆ g_MaskLiteRunLength

const BYTE g_MaskLiteRunLength = 0x0F
static

◆ g_MaskRegularRunLength

const BYTE g_MaskRegularRunLength = 0x1F
static

◆ g_MaskSpecialFgBg1

const BYTE g_MaskSpecialFgBg1 = 0x03
static

◆ g_MaskSpecialFgBg2

const BYTE g_MaskSpecialFgBg2 = 0x05
static