codec

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2026 License: GPL-3.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package codec implements the bitmap codecs that RDP servers use to encode bitmap update and surface command payloads.

A compressed bitmap update whose flags say the payload is codec-encoded begins with a one byte codec id (MS-RDPBCGR 2.2.9.1.1.3.1.2.2). Codec id zero means the payload is plain RLE; the other ids select an implementation in this package.

Index

Constants

View Source
const (
	CodecIDNone          = 0x00 // data is not encoded
	CodecIDNSCODEC       = 0x01
	CodecIDRemoteFX      = 0x03
	CodecIDImageRemoteFX = 0x04
	CodecIDX264          = 0x05
	CodecIDX264Image     = 0x06
)

Bitmap codec ids (MS-RDPBCGR 2.2.9.2.1.1, TS_BITMAP_DATA_EX.codecID).

Variables

View Source
var ErrUnsupported = errors.New("codec: unsupported bitmap codec")

ErrUnsupported reports a codec id this package cannot decode yet.

View Source
var RFXMode = RLGR1

RFXMode is the entropy coder used for RemoteFX payloads. RemoteFX data does not say which coder it used, so this has to match what was negotiated: a client advertises both ICAPs and the server picks one. RLGR1 is the safer default because every server supports it.

Change it before decoding if the session negotiated RLGR3.

Functions

func DecodeRFX

func DecodeRFX(data []byte, width, height int, mode RLGRMode) ([]byte, error)

DecodeRFX decodes a RemoteFX message (MS-RDPRFX) and returns the pixels as BGRA, top-down, matching the other decoders in this package.

width and height describe the destination surface; tiles are clipped to it and to the rectangles the message declares.

func Decompress

func Decompress(codecID uint8, data []byte, width, height, bpp int) ([]byte, error)

Decompress decodes a codec-encoded bitmap payload. codecID comes from TS_BITMAP_DATA_EX, or from the header of a cache bitmap revision 3 or EGFX surface command. A codec id of none means the payload is already raw pixels and is returned unchanged.

The result is BGRA unless the codec documents otherwise. Callers that only need to display the pixels should treat a nil error as "bpp is now 32".

func NSCodec

func NSCodec(data []byte, width, height int) ([]byte, error)

NSCodec decodes a bitmap compressed with NSCodec (MS-RDPNSC).

The encoded form is a TS_NSC_DATA header followed by four run-length encoded planes: Y, Co, Cg and A. Colour is reconstructed with the YCoCg transform. The result is BGRA, 4 bytes per pixel, rows top to bottom, which is the layout the bitmap update path uses for 32bpp data.

Types

type RLGRMode

type RLGRMode int

RLGRMode selects the entropy coder used inside a tileset.

const (
	// RLGR1 is the simpler, Golomb-Rice-only mode.
	RLGR1 RLGRMode = iota
	// RLGR3 additionally splits each coefficient into two values.
	RLGR3
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL