diff --git a/src/rfxencode_diff_rlgr1.c b/src/rfxencode_diff_rlgr1.c index cd09f18..de107df 100644 --- a/src/rfxencode_diff_rlgr1.c +++ b/src/rfxencode_diff_rlgr1.c @@ -240,6 +240,7 @@ rfx_encode_diff_rlgr1(sint16 *coef, uint8 *cdata, int cdata_size) if (bit_count > 0) { bits <<= 8 - bit_count; + bits |= ((1 << (8 - bit_count)) - 1) & *cdata; *cdata = bits; cdata++; bit_count = 0; diff --git a/src/rfxencode_diff_rlgr3.c b/src/rfxencode_diff_rlgr3.c index 0b68db3..1c275dd 100644 --- a/src/rfxencode_diff_rlgr3.c +++ b/src/rfxencode_diff_rlgr3.c @@ -277,6 +277,7 @@ rfx_encode_diff_rlgr3(sint16 *coef, uint8 *cdata, int cdata_size) if (bit_count > 0) { bits <<= 8 - bit_count; + bits |= ((1 << (8 - bit_count)) - 1) & *cdata; *cdata = bits; cdata++; bit_count = 0;