libfreerdp-rfx: output last two bits for trailing 0 is needed.

When the algorithm is in Run-Length mode and the last byte being encoded is 0, we must output the last two bits to end the stream, otherwise mstsc will treat it as protocol error and terminate the connection.
This commit is contained in:
Vic Lee
2011-08-24 21:33:15 +08:00
parent 1bc81a5cbd
commit 5c49ba7ba5

View File

@@ -344,17 +344,17 @@ int rfx_rlgr_encode(RLGR_MODE mode, const sint16* data, int data_size, uint8* bu
/* output the remaining run length using k bits */
OutputBits(k, numZeros);
if (input != 0)
{
/* encode the nonzero value using GR coding */
mag = (input < 0 ? -input : input); /* absolute value of input coefficient */
sign = (input < 0 ? 1 : 0); /* sign of input coefficient */
/* note: when we reach here and the last byte being encoded is 0, we still
need to output the last two bits, otherwise mstsc will crash */
OutputBit(1, sign); /* output the sign bit */
CodeGR(&krp, mag - 1); /* output GR code for (mag - 1) */
/* encode the nonzero value using GR coding */
mag = (input < 0 ? -input : input); /* absolute value of input coefficient */
sign = (input < 0 ? 1 : 0); /* sign of input coefficient */
UpdateParam(kp, -DN_GR, k);
}
OutputBit(1, sign); /* output the sign bit */
CodeGR(&krp, mag ? mag - 1 : 0); /* output GR code for (mag - 1) */
UpdateParam(kp, -DN_GR, k);
}
else
{