Coverage Report

Created: 2025-07-23 06:32

/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
3.46M
                                                 void *fun_ctxt) {
24
3.46M
  if (!xd->up_available) return;
25
26
3.25M
  const int num_planes = av1_num_planes(cm);
27
3.25M
  int nb_count = 0;
28
3.25M
  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
3.25M
  MB_MODE_INFO **prev_row_mi = xd->mi - mi_col - 1 * xd->mi_stride;
32
3.25M
  const int end_col = AOMMIN(mi_col + xd->width, cm->mi_params.mi_cols);
33
3.25M
  uint8_t mi_step;
34
7.00M
  for (int above_mi_col = mi_col; above_mi_col < end_col && nb_count < nb_max;
35
3.75M
       above_mi_col += mi_step) {
36
3.75M
    MB_MODE_INFO **above_mi = prev_row_mi + above_mi_col;
37
3.75M
    mi_step =
38
3.75M
        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
3.75M
    if (mi_step == 1) {
45
240k
      above_mi_col &= ~1;
46
240k
      above_mi = prev_row_mi + above_mi_col + 1;
47
240k
      mi_step = 2;
48
240k
    }
49
3.75M
    if (is_neighbor_overlappable(*above_mi)) {
50
3.35M
      ++nb_count;
51
3.35M
      fun(xd, 0, above_mi_col - mi_col, AOMMIN(xd->width, mi_step), 0,
52
3.35M
          *above_mi, fun_ctxt, num_planes);
53
3.35M
    }
54
3.75M
  }
55
3.25M
}
decodeframe.c:foreach_overlappable_nb_above
Line
Count
Source
23
472k
                                                 void *fun_ctxt) {
24
472k
  if (!xd->up_available) return;
25
26
472k
  const int num_planes = av1_num_planes(cm);
27
472k
  int nb_count = 0;
28
472k
  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
472k
  MB_MODE_INFO **prev_row_mi = xd->mi - mi_col - 1 * xd->mi_stride;
32
472k
  const int end_col = AOMMIN(mi_col + xd->width, cm->mi_params.mi_cols);
33
472k
  uint8_t mi_step;
34
1.00M
  for (int above_mi_col = mi_col; above_mi_col < end_col && nb_count < nb_max;
35
529k
       above_mi_col += mi_step) {
36
529k
    MB_MODE_INFO **above_mi = prev_row_mi + above_mi_col;
37
529k
    mi_step =
38
529k
        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
529k
    if (mi_step == 1) {
45
35.6k
      above_mi_col &= ~1;
46
35.6k
      above_mi = prev_row_mi + above_mi_col + 1;
47
35.6k
      mi_step = 2;
48
35.6k
    }
49
529k
    if (is_neighbor_overlappable(*above_mi)) {
50
479k
      ++nb_count;
51
479k
      fun(xd, 0, above_mi_col - mi_col, AOMMIN(xd->width, mi_step), 0,
52
479k
          *above_mi, fun_ctxt, num_planes);
53
479k
    }
54
529k
  }
55
472k
}
reconinter.c:foreach_overlappable_nb_above
Line
Count
Source
23
2.98M
                                                 void *fun_ctxt) {
24
2.98M
  if (!xd->up_available) return;
25
26
2.78M
  const int num_planes = av1_num_planes(cm);
27
2.78M
  int nb_count = 0;
28
2.78M
  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
2.78M
  MB_MODE_INFO **prev_row_mi = xd->mi - mi_col - 1 * xd->mi_stride;
32
2.78M
  const int end_col = AOMMIN(mi_col + xd->width, cm->mi_params.mi_cols);
33
2.78M
  uint8_t mi_step;
34
6.00M
  for (int above_mi_col = mi_col; above_mi_col < end_col && nb_count < nb_max;
35
3.22M
       above_mi_col += mi_step) {
36
3.22M
    MB_MODE_INFO **above_mi = prev_row_mi + above_mi_col;
37
3.22M
    mi_step =
38
3.22M
        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
3.22M
    if (mi_step == 1) {
45
204k
      above_mi_col &= ~1;
46
204k
      above_mi = prev_row_mi + above_mi_col + 1;
47
204k
      mi_step = 2;
48
204k
    }
49
3.22M
    if (is_neighbor_overlappable(*above_mi)) {
50
2.87M
      ++nb_count;
51
2.87M
      fun(xd, 0, above_mi_col - mi_col, AOMMIN(xd->width, mi_step), 0,
52
2.87M
          *above_mi, fun_ctxt, num_planes);
53
2.87M
    }
54
3.22M
  }
55
2.78M
}
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
1.38M
                                                void *fun_ctxt) {
61
1.38M
  if (!xd->left_available) return;
62
63
1.33M
  const int num_planes = av1_num_planes(cm);
64
1.33M
  int nb_count = 0;
65
  // prev_col_mi points into the mi array, starting at the top of the
66
  // previous column
67
1.33M
  const int mi_row = xd->mi_row;
68
1.33M
  MB_MODE_INFO **prev_col_mi = xd->mi - 1 - mi_row * xd->mi_stride;
69
1.33M
  const int end_row = AOMMIN(mi_row + xd->height, cm->mi_params.mi_rows);
70
1.33M
  uint8_t mi_step;
71
2.87M
  for (int left_mi_row = mi_row; left_mi_row < end_row && nb_count < nb_max;
72
1.54M
       left_mi_row += mi_step) {
73
1.54M
    MB_MODE_INFO **left_mi = prev_col_mi + left_mi_row * xd->mi_stride;
74
1.54M
    mi_step =
75
1.54M
        AOMMIN(mi_size_high[left_mi[0]->bsize], mi_size_high[BLOCK_64X64]);
76
1.54M
    if (mi_step == 1) {
77
123k
      left_mi_row &= ~1;
78
123k
      left_mi = prev_col_mi + (left_mi_row + 1) * xd->mi_stride;
79
123k
      mi_step = 2;
80
123k
    }
81
1.54M
    if (is_neighbor_overlappable(*left_mi)) {
82
1.35M
      ++nb_count;
83
1.35M
      fun(xd, left_mi_row - mi_row, 0, AOMMIN(xd->height, mi_step), 1, *left_mi,
84
1.35M
          fun_ctxt, num_planes);
85
1.35M
    }
86
1.54M
  }
87
1.33M
}
decodeframe.c:foreach_overlappable_nb_left
Line
Count
Source
60
475k
                                                void *fun_ctxt) {
61
475k
  if (!xd->left_available) return;
62
63
475k
  const int num_planes = av1_num_planes(cm);
64
475k
  int nb_count = 0;
65
  // prev_col_mi points into the mi array, starting at the top of the
66
  // previous column
67
475k
  const int mi_row = xd->mi_row;
68
475k
  MB_MODE_INFO **prev_col_mi = xd->mi - 1 - mi_row * xd->mi_stride;
69
475k
  const int end_row = AOMMIN(mi_row + xd->height, cm->mi_params.mi_rows);
70
475k
  uint8_t mi_step;
71
1.00M
  for (int left_mi_row = mi_row; left_mi_row < end_row && nb_count < nb_max;
72
526k
       left_mi_row += mi_step) {
73
526k
    MB_MODE_INFO **left_mi = prev_col_mi + left_mi_row * xd->mi_stride;
74
526k
    mi_step =
75
526k
        AOMMIN(mi_size_high[left_mi[0]->bsize], mi_size_high[BLOCK_64X64]);
76
526k
    if (mi_step == 1) {
77
48.3k
      left_mi_row &= ~1;
78
48.3k
      left_mi = prev_col_mi + (left_mi_row + 1) * xd->mi_stride;
79
48.3k
      mi_step = 2;
80
48.3k
    }
81
526k
    if (is_neighbor_overlappable(*left_mi)) {
82
477k
      ++nb_count;
83
477k
      fun(xd, left_mi_row - mi_row, 0, AOMMIN(xd->height, mi_step), 1, *left_mi,
84
477k
          fun_ctxt, num_planes);
85
477k
    }
86
526k
  }
87
475k
}
reconinter.c:foreach_overlappable_nb_left
Line
Count
Source
60
913k
                                                void *fun_ctxt) {
61
913k
  if (!xd->left_available) return;
62
63
855k
  const int num_planes = av1_num_planes(cm);
64
855k
  int nb_count = 0;
65
  // prev_col_mi points into the mi array, starting at the top of the
66
  // previous column
67
855k
  const int mi_row = xd->mi_row;
68
855k
  MB_MODE_INFO **prev_col_mi = xd->mi - 1 - mi_row * xd->mi_stride;
69
855k
  const int end_row = AOMMIN(mi_row + xd->height, cm->mi_params.mi_rows);
70
855k
  uint8_t mi_step;
71
1.87M
  for (int left_mi_row = mi_row; left_mi_row < end_row && nb_count < nb_max;
72
1.01M
       left_mi_row += mi_step) {
73
1.01M
    MB_MODE_INFO **left_mi = prev_col_mi + left_mi_row * xd->mi_stride;
74
1.01M
    mi_step =
75
1.01M
        AOMMIN(mi_size_high[left_mi[0]->bsize], mi_size_high[BLOCK_64X64]);
76
1.01M
    if (mi_step == 1) {
77
75.5k
      left_mi_row &= ~1;
78
75.5k
      left_mi = prev_col_mi + (left_mi_row + 1) * xd->mi_stride;
79
75.5k
      mi_step = 2;
80
75.5k
    }
81
1.01M
    if (is_neighbor_overlappable(*left_mi)) {
82
881k
      ++nb_count;
83
881k
      fun(xd, left_mi_row - mi_row, 0, AOMMIN(xd->height, mi_step), 1, *left_mi,
84
881k
          fun_ctxt, num_planes);
85
881k
    }
86
1.01M
  }
87
855k
}
88
89
#endif  // AOM_AV1_COMMON_OBMC_H_