Coverage Report

Created: 2026-10-15 06:26

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/FreeRDP/libfreerdp/codec/rfx_differential.h
Line
Count
Source
1
/**
2
 * FreeRDP: A Remote Desktop Protocol Implementation
3
 * RemoteFX Codec Library - Differential Encoding
4
 *
5
 * Copyright 2011 Vic Lee
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 */
19
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
#include "rfx_types.h"
26
27
WINPR_ATTR_NODISCARD
28
static inline BOOL rfx_differential_decode(INT16* WINPR_RESTRICT buffer, size_t size)
29
0
{
30
0
  INT16* ptr = buffer;
31
0
  INT16* end = &buffer[size - 1];
32
33
0
  while (ptr != end)
34
0
  {
35
0
    const int tmp = ptr[0] + ptr[1];
36
0
    if ((tmp > INT16_MAX) || (tmp < INT16_MIN))
37
0
    {
38
0
      WLog_ERR(RFX_TAG, "differental: %d <= %d <= %d\n", INT16_MIN, tmp, INT16_MAX);
39
0
      return FALSE;
40
0
    }
41
0
    ptr[1] = WINPR_ASSERTING_INT_CAST(INT16, tmp);
42
0
    ptr++;
43
0
  }
44
0
  return TRUE;
45
0
}
Unexecuted instantiation: progressive.c:rfx_differential_decode
Unexecuted instantiation: rfx_decode.c:rfx_differential_decode
Unexecuted instantiation: rfx_encode.c:rfx_differential_decode
46
47
static inline void rfx_differential_encode(INT16* WINPR_RESTRICT buffer, size_t size)
48
0
{
49
0
  INT16 n1 = buffer[0];
50
0
  for (size_t x = 0; x < size - 1; x++)
51
0
  {
52
0
    INT16* dst = &buffer[x + 1];
53
0
    const INT16 n2 = *dst;
54
0
    const int tmp = n2 - n1;
55
0
    *dst = WINPR_ASSERTING_INT_CAST(INT16, tmp);
56
0
    n1 = n2;
57
0
  }
58
0
}
Unexecuted instantiation: progressive.c:rfx_differential_encode
Unexecuted instantiation: rfx_decode.c:rfx_differential_encode
Unexecuted instantiation: rfx_encode.c:rfx_differential_encode
59
60
#endif /* FREERDP_LIB_CODEC_RFX_DIFFERENTIAL_H */