FreeRDP
rfx_differential.h
1 
20 #ifndef FREERDP_LIB_CODEC_RFX_DIFFERENTIAL_H
21 #define FREERDP_LIB_CODEC_RFX_DIFFERENTIAL_H
22 
23 #include <freerdp/codec/rfx.h>
24 #include <freerdp/api.h>
25 
26 static INLINE void rfx_differential_decode(INT16* WINPR_RESTRICT buffer, size_t size)
27 {
28  INT16* ptr = buffer;
29  INT16* end = &buffer[size - 1];
30 
31  while (ptr != end)
32  {
33  ptr[1] += ptr[0];
34  ptr++;
35  }
36 }
37 
38 static INLINE void rfx_differential_encode(INT16* WINPR_RESTRICT buffer, size_t size)
39 {
40  INT16 n1 = buffer[0];
41  for (size_t x = 0; x < size - 1; x++)
42  {
43  INT16* dst = &buffer[x + 1];
44  const INT16 n2 = *dst;
45  *dst -= n1;
46  n1 = n2;
47  }
48 }
49 
50 #endif /* FREERDP_LIB_CODEC_RFX_DIFFERENTIAL_H */