Coverage Report

Created: 2026-07-25 06:59

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
40.6M
int AdaptiveMedian(int w, int n, int nw) {
16
40.6M
  const int mx = (w > n) ? w : n;
17
40.6M
  const int mn = w + n - mx;
18
40.6M
  if (nw > mx) {
19
927k
    return mn;
20
39.7M
  } else if (nw < mn) {
21
778k
    return mx;
22
38.9M
  } else {
23
38.9M
    return n + w - nw;
24
38.9M
  }
25
40.6M
}
26
27
}  // namespace
28
29
41.9M
int PredictWithAdaptiveMedian(const coeff_t* coeffs, int x, int y, int stride) {
30
41.9M
  const int offset1 = -kDCTBlockSize;
31
41.9M
  const int offset2 = -stride;
32
41.9M
  const int offset3 = offset2 + offset1;
33
41.9M
  if (y != 0) {
34
41.0M
    if (x != 0) {
35
40.6M
      return AdaptiveMedian(coeffs[offset1], coeffs[offset2], coeffs[offset3]);
36
40.6M
    } else {
37
330k
      return coeffs[offset2];
38
330k
    }
39
41.0M
  } else {
40
941k
    return x ? coeffs[offset1] : 0;
41
941k
  }
42
41.9M
}
43
44
}  // namespace brunsli