Coverage Report

Created: 2023-06-07 06:31

/src/aom/av1/common/obmc.h
Line
Count
Source
1
/*
2
 * Copyright (c) 2017, Alliance for Open Media. All rights reserved
3
 *
4
 * This source code is subject to the terms of the BSD 2 Clause License and
5
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6
 * was not distributed with this source code in the LICENSE file, you can
7
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8
 * Media Patent License 1.0 was not distributed with this source code in the
9
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10
 */
11
12
#ifndef AOM_AV1_COMMON_OBMC_H_
13
#define AOM_AV1_COMMON_OBMC_H_
14
15
typedef void (*overlappable_nb_visitor_t)(MACROBLOCKD *xd, int rel_mi_row,
16
                                          int rel_mi_col, uint8_t op_mi_size,
17
                                          int dir, MB_MODE_INFO *nb_mi,
18
                                          void *fun_ctxt, const int num_planes);
19
20
static INLINE void foreach_overlappable_nb_above(const AV1_COMMON *cm,
21
                                                 MACROBLOCKD *xd, int nb_max,
22
                                                 overlappable_nb_visitor_t fun,
23
6.30M
                                                 void *fun_ctxt) {
24
6.30M
  if (!xd->up_available) return;
25
26
6.11M
  const int num_planes = av1_num_planes(cm);
27
6.11M
  int nb_count = 0;
28
6.11M
  const int mi_col = xd->mi_col;
29
  // prev_row_mi points into the mi array, starting at the beginning of the
30
  // previous row.
31
6.11M
  MB_MODE_INFO **prev_row_mi = xd->mi - mi_col - 1 * xd->mi_stride;
32
6.11M
  const int end_col = AOMMIN(mi_col + xd->width, cm->mi_params.mi_cols);
33
6.11M
  uint8_t mi_step;
34
13.1M
  for (int above_mi_col = mi_col; above_mi_col < end_col && nb_count < nb_max;
35
7.05M
       above_mi_col += mi_step) {
36
7.05M
    MB_MODE_INFO **above_mi = prev_row_mi + above_mi_col;
37
7.05M
    mi_step =
38
7.05M
        AOMMIN(mi_size_wide[above_mi[0]->bsize], mi_size_wide[BLOCK_64X64]);
39
    // If we're considering a block with width 4, it should be treated as
40
    // half of a pair of blocks with chroma information in the second. Move
41
    // above_mi_col back to the start of the pair if needed, set above_mbmi
42
    // to point at the block with chroma information, and set mi_step to 2 to
43
    // step over the entire pair at the end of the iteration.
44
7.05M
    if (mi_step == 1) {
45
501k
      above_mi_col &= ~1;
46
501k
      above_mi = prev_row_mi + above_mi_col + 1;
47
501k
      mi_step = 2;
48
501k
    }
49
7.05M
    if (is_neighbor_overlappable(*above_mi)) {
50
6.38M
      ++nb_count;
51
6.38M
      fun(xd, 0, above_mi_col - mi_col, AOMMIN(xd->width, mi_step), 0,
52
6.38M
          *above_mi, fun_ctxt, num_planes);
53
6.38M
    }
54
7.05M
  }
55
6.11M
}
decodeframe.c:foreach_overlappable_nb_above
Line
Count
Source
23
1.07M
                                                 void *fun_ctxt) {
24
1.07M
  if (!xd->up_available) return;
25
26
1.07M
  const int num_planes = av1_num_planes(cm);
27
1.07M
  int nb_count = 0;
28
1.07M
  const int mi_col = xd->mi_col;
29
  // prev_row_mi points into the mi array, starting at the beginning of the
30
  // previous row.
31
1.07M
  MB_MODE_INFO **prev_row_mi = xd->mi - mi_col - 1 * xd->mi_stride;
32
1.07M
  const int end_col = AOMMIN(mi_col + xd->width, cm->mi_params.mi_cols);
33
1.07M
  uint8_t mi_step;
34
2.28M
  for (int above_mi_col = mi_col; above_mi_col < end_col && nb_count < nb_max;
35
1.21M
       above_mi_col += mi_step) {
36
1.21M
    MB_MODE_INFO **above_mi = prev_row_mi + above_mi_col;
37
1.21M
    mi_step =
38
1.21M
        AOMMIN(mi_size_wide[above_mi[0]->bsize], mi_size_wide[BLOCK_64X64]);
39
    // If we're considering a block with width 4, it should be treated as
40
    // half of a pair of blocks with chroma information in the second. Move
41
    // above_mi_col back to the start of the pair if needed, set above_mbmi
42
    // to point at the block with chroma information, and set mi_step to 2 to
43
    // step over the entire pair at the end of the iteration.
44
1.21M
    if (mi_step == 1) {
45
86.9k
      above_mi_col &= ~1;
46
86.9k
      above_mi = prev_row_mi + above_mi_col + 1;
47
86.9k
      mi_step = 2;
48
86.9k
    }
49
1.21M
    if (is_neighbor_overlappable(*above_mi)) {
50
1.12M
      ++nb_count;
51
1.12M
      fun(xd, 0, above_mi_col - mi_col, AOMMIN(xd->width, mi_step), 0,
52
1.12M
          *above_mi, fun_ctxt, num_planes);
53
1.12M
    }
54
1.21M
  }
55
1.07M
}
reconinter.c:foreach_overlappable_nb_above
Line
Count
Source
23
5.23M
                                                 void *fun_ctxt) {
24
5.23M
  if (!xd->up_available) return;
25
26
5.04M
  const int num_planes = av1_num_planes(cm);
27
5.04M
  int nb_count = 0;
28
5.04M
  const int mi_col = xd->mi_col;
29
  // prev_row_mi points into the mi array, starting at the beginning of the
30
  // previous row.
31
5.04M
  MB_MODE_INFO **prev_row_mi = xd->mi - mi_col - 1 * xd->mi_stride;
32
5.04M
  const int end_col = AOMMIN(mi_col + xd->width, cm->mi_params.mi_cols);
33
5.04M
  uint8_t mi_step;
34
10.8M
  for (int above_mi_col = mi_col; above_mi_col < end_col && nb_count < nb_max;
35
5.84M
       above_mi_col += mi_step) {
36
5.84M
    MB_MODE_INFO **above_mi = prev_row_mi + above_mi_col;
37
5.84M
    mi_step =
38
5.84M
        AOMMIN(mi_size_wide[above_mi[0]->bsize], mi_size_wide[BLOCK_64X64]);
39
    // If we're considering a block with width 4, it should be treated as
40
    // half of a pair of blocks with chroma information in the second. Move
41
    // above_mi_col back to the start of the pair if needed, set above_mbmi
42
    // to point at the block with chroma information, and set mi_step to 2 to
43
    // step over the entire pair at the end of the iteration.
44
5.84M
    if (mi_step == 1) {
45
414k
      above_mi_col &= ~1;
46
414k
      above_mi = prev_row_mi + above_mi_col + 1;
47
414k
      mi_step = 2;
48
414k
    }
49
5.84M
    if (is_neighbor_overlappable(*above_mi)) {
50
5.26M
      ++nb_count;
51
5.26M
      fun(xd, 0, above_mi_col - mi_col, AOMMIN(xd->width, mi_step), 0,
52
5.26M
          *above_mi, fun_ctxt, num_planes);
53
5.26M
    }
54
5.84M
  }
55
5.04M
}
56
57
static INLINE void foreach_overlappable_nb_left(const AV1_COMMON *cm,
58
                                                MACROBLOCKD *xd, int nb_max,
59
                                                overlappable_nb_visitor_t fun,
60
2.72M
                                                void *fun_ctxt) {
61
2.72M
  if (!xd->left_available) return;
62
63
2.67M
  const int num_planes = av1_num_planes(cm);
64
2.67M
  int nb_count = 0;
65
  // prev_col_mi points into the mi array, starting at the top of the
66
  // previous column
67
2.67M
  const int mi_row = xd->mi_row;
68
2.67M
  MB_MODE_INFO **prev_col_mi = xd->mi - 1 - mi_row * xd->mi_stride;
69
2.67M
  const int end_row = AOMMIN(mi_row + xd->height, cm->mi_params.mi_rows);
70
2.67M
  uint8_t mi_step;
71
5.71M
  for (int left_mi_row = mi_row; left_mi_row < end_row && nb_count < nb_max;
72
3.04M
       left_mi_row += mi_step) {
73
3.04M
    MB_MODE_INFO **left_mi = prev_col_mi + left_mi_row * xd->mi_stride;
74
3.04M
    mi_step =
75
3.04M
        AOMMIN(mi_size_high[left_mi[0]->bsize], mi_size_high[BLOCK_64X64]);
76
3.04M
    if (mi_step == 1) {
77
270k
      left_mi_row &= ~1;
78
270k
      left_mi = prev_col_mi + (left_mi_row + 1) * xd->mi_stride;
79
270k
      mi_step = 2;
80
270k
    }
81
3.04M
    if (is_neighbor_overlappable(*left_mi)) {
82
2.72M
      ++nb_count;
83
2.72M
      fun(xd, left_mi_row - mi_row, 0, AOMMIN(xd->height, mi_step), 1, *left_mi,
84
2.72M
          fun_ctxt, num_planes);
85
2.72M
    }
86
3.04M
  }
87
2.67M
}
decodeframe.c:foreach_overlappable_nb_left
Line
Count
Source
60
1.07M
                                                void *fun_ctxt) {
61
1.07M
  if (!xd->left_available) return;
62
63
1.07M
  const int num_planes = av1_num_planes(cm);
64
1.07M
  int nb_count = 0;
65
  // prev_col_mi points into the mi array, starting at the top of the
66
  // previous column
67
1.07M
  const int mi_row = xd->mi_row;
68
1.07M
  MB_MODE_INFO **prev_col_mi = xd->mi - 1 - mi_row * xd->mi_stride;
69
1.07M
  const int end_row = AOMMIN(mi_row + xd->height, cm->mi_params.mi_rows);
70
1.07M
  uint8_t mi_step;
71
2.27M
  for (int left_mi_row = mi_row; left_mi_row < end_row && nb_count < nb_max;
72
1.19M
       left_mi_row += mi_step) {
73
1.19M
    MB_MODE_INFO **left_mi = prev_col_mi + left_mi_row * xd->mi_stride;
74
1.19M
    mi_step =
75
1.19M
        AOMMIN(mi_size_high[left_mi[0]->bsize], mi_size_high[BLOCK_64X64]);
76
1.19M
    if (mi_step == 1) {
77
116k
      left_mi_row &= ~1;
78
116k
      left_mi = prev_col_mi + (left_mi_row + 1) * xd->mi_stride;
79
116k
      mi_step = 2;
80
116k
    }
81
1.19M
    if (is_neighbor_overlappable(*left_mi)) {
82
1.11M
      ++nb_count;
83
1.11M
      fun(xd, left_mi_row - mi_row, 0, AOMMIN(xd->height, mi_step), 1, *left_mi,
84
1.11M
          fun_ctxt, num_planes);
85
1.11M
    }
86
1.19M
  }
87
1.07M
}
reconinter.c:foreach_overlappable_nb_left
Line
Count
Source
60
1.65M
                                                void *fun_ctxt) {
61
1.65M
  if (!xd->left_available) return;
62
63
1.60M
  const int num_planes = av1_num_planes(cm);
64
1.60M
  int nb_count = 0;
65
  // prev_col_mi points into the mi array, starting at the top of the
66
  // previous column
67
1.60M
  const int mi_row = xd->mi_row;
68
1.60M
  MB_MODE_INFO **prev_col_mi = xd->mi - 1 - mi_row * xd->mi_stride;
69
1.60M
  const int end_row = AOMMIN(mi_row + xd->height, cm->mi_params.mi_rows);
70
1.60M
  uint8_t mi_step;
71
3.44M
  for (int left_mi_row = mi_row; left_mi_row < end_row && nb_count < nb_max;
72
1.84M
       left_mi_row += mi_step) {
73
1.84M
    MB_MODE_INFO **left_mi = prev_col_mi + left_mi_row * xd->mi_stride;
74
1.84M
    mi_step =
75
1.84M
        AOMMIN(mi_size_high[left_mi[0]->bsize], mi_size_high[BLOCK_64X64]);
76
1.84M
    if (mi_step == 1) {
77
154k
      left_mi_row &= ~1;
78
154k
      left_mi = prev_col_mi + (left_mi_row + 1) * xd->mi_stride;
79
154k
      mi_step = 2;
80
154k
    }
81
1.84M
    if (is_neighbor_overlappable(*left_mi)) {
82
1.61M
      ++nb_count;
83
1.61M
      fun(xd, left_mi_row - mi_row, 0, AOMMIN(xd->height, mi_step), 1, *left_mi,
84
1.61M
          fun_ctxt, num_planes);
85
1.61M
    }
86
1.84M
  }
87
1.60M
}
88
89
#endif  // AOM_AV1_COMMON_OBMC_H_