libfreerdp-rfx: fix wrong RLGR1 encoding.
authorVic Lee <llyzs@163.com>
Wed, 24 Aug 2011 10:02:34 +0000 (18:02 +0800)
committerVic Lee <llyzs@163.com>
Wed, 24 Aug 2011 10:02:34 +0000 (18:02 +0800)
libfreerdp-rfx/rfx_rlgr.c

index a8cc8d8..f915afa 100644 (file)
@@ -262,13 +262,13 @@ int rfx_rlgr_decode(RLGR_MODE mode, const uint8* data, int data_size, sint16* bu
 /* Outputs the Golomb/Rice encoding of a non-negative integer */
 #define CodeGR(krp, val) rfx_rlgr_code_gr(bs, krp, val)
 
-static void rfx_rlgr_code_gr(RFX_BITSTREAM* bs, int* krp, uint16 val)
+static void rfx_rlgr_code_gr(RFX_BITSTREAM* bs, int* krp, uint32 val)
 {
        int kr = *krp >> LSGR;
 
        /* unary part of GR code */
 
-       uint16 vk = (val) >> kr;
+       uint32 vk = (val) >> kr;
        OutputBit(vk, 1);
        OutputBit(1, 0);
 
@@ -372,13 +372,15 @@ int rfx_rlgr_encode(RLGR_MODE mode, const sint16* data, int data_size, uint8* bu
                                CodeGR(&krp, twoMs);
 
                                /* update k, kp */
+                               /* NOTE: as of Aug 2011, the algorithm is still wrongly documented
+                                  and the update direction is reversed */
                                if (twoMs)
                                {
-                                       UpdateParam(kp, UQ_GR, k);
+                                       UpdateParam(kp, -DQ_GR, k);
                                }
                                else
                                {
-                                       UpdateParam(kp, -DQ_GR, k);
+                                       UpdateParam(kp, UQ_GR, k);
                                }
                        }
                        else /* mode == RLGR3 */