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 ¶
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 ¶
var ErrUnsupported = errors.New("codec: unsupported bitmap codec")
ErrUnsupported reports a codec id this package cannot decode yet.
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 ¶
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 ¶
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 ¶
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.