Coverage Report

Created: 2025-12-14 06:36

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/brunsli/c/common/predict.cc
Line
Count
Source
1
// Copyright (c) Google LLC 2019
2
//
3
// Use of this source code is governed by an MIT-style
4
// license that can be found in the LICENSE file or at
5
// https://opensource.org/licenses/MIT.
6
7
#include "./predict.h"
8
9
#include <brunsli/jpeg_data.h>
10
11
namespace brunsli {
12
13
namespace {
14
15
73.0M
int AdaptiveMedian(int w, int n, int nw) {
16
73.0M
  const int mx = (w > n) ? w : n;
17
73.0M
  const int mn = w + n - mx;
18
73.0M
  if (nw > mx) {
19
2.22M
    return mn;
20
70.8M
  } else if (nw < mn) {
21
1.22M
    return mx;
22
69.5M
  } else {
23
69.5M
    return n + w - nw;
24
69.5M
  }
25
73.0M
}
26
27
}  // namespace
28
29
75.5M
int PredictWithAdaptiveMedian(const coeff_t* coeffs, int x, int y, int stride) {
30
75.5M
  const int offset1 = -kDCTBlockSize;
31
75.5M
  const int offset2 = -stride;
32
75.5M
  const int offset3 = offset2 + offset1;
33
75.5M
  if (y != 0) {
34
73.7M
    if (x != 0) {
35
73.0M
      return AdaptiveMedian(coeffs[offset1], coeffs[offset2], coeffs[offset3]);
36
73.0M
    } else {
37
657k
      return coeffs[offset2];
38
657k
    }
39
73.7M
  } else {
40
1.82M
    return x ? coeffs[offset1] : 0;
41
1.82M
  }
42
75.5M
}
43
44
}  // namespace brunsli