/src/mozilla-central/third_party/aom/av1/common/blockd.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2016, 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 | | #include <math.h> |
13 | | |
14 | | #include "aom_ports/system_state.h" |
15 | | |
16 | | #include "av1/common/blockd.h" |
17 | | #include "av1/common/onyxc_int.h" |
18 | | |
19 | 0 | PREDICTION_MODE av1_left_block_mode(const MB_MODE_INFO *left_mi) { |
20 | 0 | if (!left_mi) return DC_PRED; |
21 | 0 | assert(!is_inter_block(left_mi) || is_intrabc_block(left_mi)); |
22 | 0 | return left_mi->mode; |
23 | 0 | } |
24 | | |
25 | 0 | PREDICTION_MODE av1_above_block_mode(const MB_MODE_INFO *above_mi) { |
26 | 0 | if (!above_mi) return DC_PRED; |
27 | 0 | assert(!is_inter_block(above_mi) || is_intrabc_block(above_mi)); |
28 | 0 | return above_mi->mode; |
29 | 0 | } |
30 | | |
31 | | void av1_set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd, |
32 | | int plane, BLOCK_SIZE plane_bsize, TX_SIZE tx_size, |
33 | 0 | int has_eob, int aoff, int loff) { |
34 | 0 | ENTROPY_CONTEXT *const a = pd->above_context + aoff; |
35 | 0 | ENTROPY_CONTEXT *const l = pd->left_context + loff; |
36 | 0 | const int txs_wide = tx_size_wide_unit[tx_size]; |
37 | 0 | const int txs_high = tx_size_high_unit[tx_size]; |
38 | 0 |
|
39 | 0 | // above |
40 | 0 | if (has_eob && xd->mb_to_right_edge < 0) { |
41 | 0 | const int blocks_wide = max_block_wide(xd, plane_bsize, plane); |
42 | 0 | const int above_contexts = AOMMIN(txs_wide, blocks_wide - aoff); |
43 | 0 | memset(a, has_eob, sizeof(*a) * above_contexts); |
44 | 0 | memset(a + above_contexts, 0, sizeof(*a) * (txs_wide - above_contexts)); |
45 | 0 | } else { |
46 | 0 | memset(a, has_eob, sizeof(*a) * txs_wide); |
47 | 0 | } |
48 | 0 |
|
49 | 0 | // left |
50 | 0 | if (has_eob && xd->mb_to_bottom_edge < 0) { |
51 | 0 | const int blocks_high = max_block_high(xd, plane_bsize, plane); |
52 | 0 | const int left_contexts = AOMMIN(txs_high, blocks_high - loff); |
53 | 0 | memset(l, has_eob, sizeof(*l) * left_contexts); |
54 | 0 | memset(l + left_contexts, 0, sizeof(*l) * (txs_high - left_contexts)); |
55 | 0 | } else { |
56 | 0 | memset(l, has_eob, sizeof(*l) * txs_high); |
57 | 0 | } |
58 | 0 | } |
59 | | void av1_reset_skip_context(MACROBLOCKD *xd, int mi_row, int mi_col, |
60 | 0 | BLOCK_SIZE bsize, const int num_planes) { |
61 | 0 | int i; |
62 | 0 | int nplanes; |
63 | 0 | int chroma_ref; |
64 | 0 | chroma_ref = |
65 | 0 | is_chroma_reference(mi_row, mi_col, bsize, xd->plane[1].subsampling_x, |
66 | 0 | xd->plane[1].subsampling_y); |
67 | 0 | nplanes = 1 + (num_planes - 1) * chroma_ref; |
68 | 0 | for (i = 0; i < nplanes; i++) { |
69 | 0 | struct macroblockd_plane *const pd = &xd->plane[i]; |
70 | 0 | const BLOCK_SIZE plane_bsize = |
71 | 0 | get_plane_block_size(bsize, pd->subsampling_x, pd->subsampling_y); |
72 | 0 | const int txs_wide = block_size_wide[plane_bsize] >> tx_size_wide_log2[0]; |
73 | 0 | const int txs_high = block_size_high[plane_bsize] >> tx_size_high_log2[0]; |
74 | 0 | memset(pd->above_context, 0, sizeof(ENTROPY_CONTEXT) * txs_wide); |
75 | 0 | memset(pd->left_context, 0, sizeof(ENTROPY_CONTEXT) * txs_high); |
76 | 0 | } |
77 | 0 | } |
78 | | |
79 | 0 | void av1_reset_loop_filter_delta(MACROBLOCKD *xd, int num_planes) { |
80 | 0 | xd->delta_lf_from_base = 0; |
81 | 0 | const int frame_lf_count = |
82 | 0 | num_planes > 1 ? FRAME_LF_COUNT : FRAME_LF_COUNT - 2; |
83 | 0 | for (int lf_id = 0; lf_id < frame_lf_count; ++lf_id) xd->delta_lf[lf_id] = 0; |
84 | 0 | } |
85 | | |
86 | 0 | void av1_reset_loop_restoration(MACROBLOCKD *xd, const int num_planes) { |
87 | 0 | for (int p = 0; p < num_planes; ++p) { |
88 | 0 | set_default_wiener(xd->wiener_info + p); |
89 | 0 | set_default_sgrproj(xd->sgrproj_info + p); |
90 | 0 | } |
91 | 0 | } |
92 | | |
93 | | void av1_setup_block_planes(MACROBLOCKD *xd, int ss_x, int ss_y, |
94 | 0 | const int num_planes) { |
95 | 0 | int i; |
96 | 0 |
|
97 | 0 | for (i = 0; i < num_planes; i++) { |
98 | 0 | xd->plane[i].plane_type = get_plane_type(i); |
99 | 0 | xd->plane[i].subsampling_x = i ? ss_x : 0; |
100 | 0 | xd->plane[i].subsampling_y = i ? ss_y : 0; |
101 | 0 | } |
102 | 0 | for (i = num_planes; i < MAX_MB_PLANE; i++) { |
103 | 0 | xd->plane[i].subsampling_x = 1; |
104 | 0 | xd->plane[i].subsampling_y = 1; |
105 | 0 | } |
106 | 0 | } |
107 | | |
108 | | const int16_t dr_intra_derivative[90] = { |
109 | | // More evenly spread out angles and limited to 10-bit |
110 | | // Values that are 0 will never be used |
111 | | // Approx angle |
112 | | 0, 0, 0, // |
113 | | 1023, 0, 0, // 3, ... |
114 | | 547, 0, 0, // 6, ... |
115 | | 372, 0, 0, 0, 0, // 9, ... |
116 | | 273, 0, 0, // 14, ... |
117 | | 215, 0, 0, // 17, ... |
118 | | 178, 0, 0, // 20, ... |
119 | | 151, 0, 0, // 23, ... (113 & 203 are base angles) |
120 | | 132, 0, 0, // 26, ... |
121 | | 116, 0, 0, // 29, ... |
122 | | 102, 0, 0, 0, // 32, ... |
123 | | 90, 0, 0, // 36, ... |
124 | | 80, 0, 0, // 39, ... |
125 | | 71, 0, 0, // 42, ... |
126 | | 64, 0, 0, // 45, ... (45 & 135 are base angles) |
127 | | 57, 0, 0, // 48, ... |
128 | | 51, 0, 0, // 51, ... |
129 | | 45, 0, 0, 0, // 54, ... |
130 | | 40, 0, 0, // 58, ... |
131 | | 35, 0, 0, // 61, ... |
132 | | 31, 0, 0, // 64, ... |
133 | | 27, 0, 0, // 67, ... (67 & 157 are base angles) |
134 | | 23, 0, 0, // 70, ... |
135 | | 19, 0, 0, // 73, ... |
136 | | 15, 0, 0, 0, 0, // 76, ... |
137 | | 11, 0, 0, // 81, ... |
138 | | 7, 0, 0, // 84, ... |
139 | | 3, 0, 0, // 87, ... |
140 | | }; |