/src/libavif/ext/aom/av1/encoder/model_rd.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2020, 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_ENCODER_MODEL_RD_H_ |
13 | | #define AOM_AV1_ENCODER_MODEL_RD_H_ |
14 | | |
15 | | #include "aom/aom_integer.h" |
16 | | #include "av1/encoder/block.h" |
17 | | #include "av1/encoder/encoder.h" |
18 | | #include "av1/encoder/pustats.h" |
19 | | #include "av1/encoder/rdopt_utils.h" |
20 | | #include "config/aom_dsp_rtcd.h" |
21 | | |
22 | | #ifdef __cplusplus |
23 | | extern "C" { |
24 | | #endif |
25 | | |
26 | | // 0: Legacy model |
27 | | // 1: Curve fit model |
28 | | // 2: Surface fit model |
29 | | // 3: DNN regression model |
30 | | // 4: Full rd model |
31 | 2.88M | #define MODELRD_TYPE_INTERP_FILTER 1 |
32 | 0 | #define MODELRD_TYPE_TX_SEARCH_PRUNE 1 |
33 | 0 | #define MODELRD_TYPE_MASKED_COMPOUND 1 |
34 | 0 | #define MODELRD_TYPE_INTERINTRA 1 |
35 | | #define MODELRD_TYPE_INTRA 1 |
36 | 48.4k | #define MODELRD_TYPE_MOTION_MODE_RD 1 |
37 | | |
38 | | typedef void (*model_rd_for_sb_type)( |
39 | | const AV1_COMP *const cpi, BLOCK_SIZE bsize, MACROBLOCK *x, MACROBLOCKD *xd, |
40 | | int plane_from, int plane_to, int *out_rate_sum, int64_t *out_dist_sum, |
41 | | uint8_t *skip_txfm_sb, int64_t *skip_sse_sb, int *plane_rate, |
42 | | int64_t *plane_sse, int64_t *plane_dist); |
43 | | typedef void (*model_rd_from_sse_type)(const AV1_COMP *const cpi, |
44 | | const MACROBLOCK *const x, |
45 | | BLOCK_SIZE plane_bsize, int plane, |
46 | | int64_t sse, int num_samples, int *rate, |
47 | | int64_t *dist); |
48 | | |
49 | | static int64_t calculate_sse(MACROBLOCKD *const xd, |
50 | | const struct macroblock_plane *p, |
51 | | struct macroblockd_plane *pd, const int bw, |
52 | 3.64M | const int bh) { |
53 | 3.64M | int64_t sse = 0; |
54 | 3.64M | const int shift = xd->bd - 8; |
55 | 3.64M | #if CONFIG_AV1_HIGHBITDEPTH |
56 | 3.64M | if (is_cur_buf_hbd(xd)) { |
57 | 343k | sse = aom_highbd_sse(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, |
58 | 343k | bw, bh); |
59 | 3.29M | } else { |
60 | 3.29M | sse = |
61 | 3.29M | aom_sse(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, bw, bh); |
62 | 3.29M | } |
63 | | #else |
64 | | sse = aom_sse(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, bw, bh); |
65 | | #endif |
66 | 3.64M | sse = ROUND_POWER_OF_TWO(sse, shift * 2); |
67 | 3.64M | return sse; |
68 | 3.64M | } Unexecuted instantiation: av1_cx_iface.c:calculate_sse Unexecuted instantiation: allintra_vis.c:calculate_sse Unexecuted instantiation: encodeframe.c:calculate_sse Unexecuted instantiation: encoder.c:calculate_sse Unexecuted instantiation: encoder_utils.c:calculate_sse Unexecuted instantiation: ethread.c:calculate_sse Unexecuted instantiation: palette.c:calculate_sse Unexecuted instantiation: partition_search.c:calculate_sse Line | Count | Source | 52 | 97.1k | const int bh) { | 53 | 97.1k | int64_t sse = 0; | 54 | 97.1k | const int shift = xd->bd - 8; | 55 | 97.1k | #if CONFIG_AV1_HIGHBITDEPTH | 56 | 97.1k | if (is_cur_buf_hbd(xd)) { | 57 | 20.5k | sse = aom_highbd_sse(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, | 58 | 20.5k | bw, bh); | 59 | 76.6k | } else { | 60 | 76.6k | sse = | 61 | 76.6k | aom_sse(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, bw, bh); | 62 | 76.6k | } | 63 | | #else | 64 | | sse = aom_sse(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, bw, bh); | 65 | | #endif | 66 | 97.1k | sse = ROUND_POWER_OF_TWO(sse, shift * 2); | 67 | 97.1k | return sse; | 68 | 97.1k | } |
Unexecuted instantiation: nonrd_pickmode.c:calculate_sse Unexecuted instantiation: superres_scale.c:calculate_sse Unexecuted instantiation: svc_layercontext.c:calculate_sse Unexecuted instantiation: temporal_filter.c:calculate_sse Unexecuted instantiation: tx_search.c:calculate_sse Unexecuted instantiation: intra_mode_search.c:calculate_sse Unexecuted instantiation: compound_type.c:calculate_sse Unexecuted instantiation: encode_strategy.c:calculate_sse interp_search.c:calculate_sse Line | Count | Source | 52 | 3.54M | const int bh) { | 53 | 3.54M | int64_t sse = 0; | 54 | 3.54M | const int shift = xd->bd - 8; | 55 | 3.54M | #if CONFIG_AV1_HIGHBITDEPTH | 56 | 3.54M | if (is_cur_buf_hbd(xd)) { | 57 | 323k | sse = aom_highbd_sse(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, | 58 | 323k | bw, bh); | 59 | 3.22M | } else { | 60 | 3.22M | sse = | 61 | 3.22M | aom_sse(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, bw, bh); | 62 | 3.22M | } | 63 | | #else | 64 | | sse = aom_sse(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride, bw, bh); | 65 | | #endif | 66 | 3.54M | sse = ROUND_POWER_OF_TWO(sse, shift * 2); | 67 | 3.54M | return sse; | 68 | 3.54M | } |
|
69 | | |
70 | | static inline int64_t compute_sse_plane(MACROBLOCK *x, MACROBLOCKD *xd, |
71 | 0 | int plane, const BLOCK_SIZE bsize) { |
72 | 0 | struct macroblockd_plane *const pd = &xd->plane[plane]; |
73 | 0 | const BLOCK_SIZE plane_bsize = |
74 | 0 | get_plane_block_size(bsize, pd->subsampling_x, pd->subsampling_y); |
75 | 0 | int bw, bh; |
76 | 0 | const struct macroblock_plane *const p = &x->plane[plane]; |
77 | 0 | get_txb_dimensions(xd, plane, plane_bsize, 0, 0, plane_bsize, NULL, NULL, &bw, |
78 | 0 | &bh); |
79 | |
|
80 | 0 | int64_t sse = calculate_sse(xd, p, pd, bw, bh); |
81 | |
|
82 | 0 | return sse; |
83 | 0 | } Unexecuted instantiation: av1_cx_iface.c:compute_sse_plane Unexecuted instantiation: allintra_vis.c:compute_sse_plane Unexecuted instantiation: encodeframe.c:compute_sse_plane Unexecuted instantiation: encoder.c:compute_sse_plane Unexecuted instantiation: encoder_utils.c:compute_sse_plane Unexecuted instantiation: ethread.c:compute_sse_plane Unexecuted instantiation: palette.c:compute_sse_plane Unexecuted instantiation: partition_search.c:compute_sse_plane Unexecuted instantiation: rdopt.c:compute_sse_plane Unexecuted instantiation: nonrd_pickmode.c:compute_sse_plane Unexecuted instantiation: superres_scale.c:compute_sse_plane Unexecuted instantiation: svc_layercontext.c:compute_sse_plane Unexecuted instantiation: temporal_filter.c:compute_sse_plane Unexecuted instantiation: tx_search.c:compute_sse_plane Unexecuted instantiation: intra_mode_search.c:compute_sse_plane Unexecuted instantiation: compound_type.c:compute_sse_plane Unexecuted instantiation: encode_strategy.c:compute_sse_plane Unexecuted instantiation: interp_search.c:compute_sse_plane |
84 | | |
85 | | static inline void model_rd_from_sse(const AV1_COMP *const cpi, |
86 | | const MACROBLOCK *const x, |
87 | | BLOCK_SIZE plane_bsize, int plane, |
88 | | int64_t sse, int num_samples, int *rate, |
89 | 0 | int64_t *dist) { |
90 | 0 | (void)num_samples; |
91 | 0 | const MACROBLOCKD *const xd = &x->e_mbd; |
92 | 0 | const struct macroblock_plane *const p = &x->plane[plane]; |
93 | 0 | const int dequant_shift = (is_cur_buf_hbd(xd)) ? xd->bd - 5 : 3; |
94 | | |
95 | | // Fast approximate the modelling function. |
96 | 0 | if (cpi->sf.rd_sf.simple_model_rd_from_var) { |
97 | 0 | const int64_t square_error = sse; |
98 | 0 | int quantizer = p->dequant_QTX[1] >> dequant_shift; |
99 | 0 | if (quantizer < 120) |
100 | 0 | *rate = (int)AOMMIN( |
101 | 0 | (square_error * (280 - quantizer)) >> (16 - AV1_PROB_COST_SHIFT), |
102 | 0 | INT_MAX); |
103 | 0 | else |
104 | 0 | *rate = 0; |
105 | 0 | assert(*rate >= 0); |
106 | 0 | *dist = (square_error * quantizer) >> 8; |
107 | 0 | } else { |
108 | 0 | av1_model_rd_from_var_lapndz(sse, num_pels_log2_lookup[plane_bsize], |
109 | 0 | p->dequant_QTX[1] >> dequant_shift, rate, |
110 | 0 | dist); |
111 | 0 | } |
112 | 0 | *dist <<= 4; |
113 | 0 | } Unexecuted instantiation: av1_cx_iface.c:model_rd_from_sse Unexecuted instantiation: allintra_vis.c:model_rd_from_sse Unexecuted instantiation: encodeframe.c:model_rd_from_sse Unexecuted instantiation: encoder.c:model_rd_from_sse Unexecuted instantiation: encoder_utils.c:model_rd_from_sse Unexecuted instantiation: ethread.c:model_rd_from_sse Unexecuted instantiation: palette.c:model_rd_from_sse Unexecuted instantiation: partition_search.c:model_rd_from_sse Unexecuted instantiation: rdopt.c:model_rd_from_sse Unexecuted instantiation: nonrd_pickmode.c:model_rd_from_sse Unexecuted instantiation: superres_scale.c:model_rd_from_sse Unexecuted instantiation: svc_layercontext.c:model_rd_from_sse Unexecuted instantiation: temporal_filter.c:model_rd_from_sse Unexecuted instantiation: tx_search.c:model_rd_from_sse Unexecuted instantiation: intra_mode_search.c:model_rd_from_sse Unexecuted instantiation: compound_type.c:model_rd_from_sse Unexecuted instantiation: encode_strategy.c:model_rd_from_sse Unexecuted instantiation: interp_search.c:model_rd_from_sse |
114 | | |
115 | | // Fits a curve for rate and distortion using as feature: |
116 | | // log2(sse_norm/qstep^2) |
117 | | static inline void model_rd_with_curvfit(const AV1_COMP *const cpi, |
118 | | const MACROBLOCK *const x, |
119 | | BLOCK_SIZE plane_bsize, int plane, |
120 | | int64_t sse, int num_samples, |
121 | 5.81M | int *rate, int64_t *dist) { |
122 | 5.81M | (void)cpi; |
123 | 5.81M | (void)plane_bsize; |
124 | 5.81M | const MACROBLOCKD *const xd = &x->e_mbd; |
125 | 5.81M | const struct macroblock_plane *const p = &x->plane[plane]; |
126 | 5.81M | const int dequant_shift = (is_cur_buf_hbd(xd)) ? xd->bd - 5 : 3; |
127 | 5.81M | const int qstep = AOMMAX(p->dequant_QTX[1] >> dequant_shift, 1); |
128 | | |
129 | 5.81M | if (sse == 0) { |
130 | 195 | if (rate) *rate = 0; |
131 | 195 | if (dist) *dist = 0; |
132 | 195 | return; |
133 | 195 | } |
134 | 5.81M | const double sse_norm = (double)sse / num_samples; |
135 | 5.81M | const double qstepsqr = (double)qstep * qstep; |
136 | 5.81M | const double xqr = log2(sse_norm / qstepsqr); |
137 | 5.81M | double rate_f, dist_by_sse_norm_f; |
138 | 5.81M | av1_model_rd_curvfit(plane_bsize, sse_norm, xqr, &rate_f, |
139 | 5.81M | &dist_by_sse_norm_f); |
140 | | |
141 | 5.81M | const double dist_f = dist_by_sse_norm_f * sse_norm; |
142 | 5.81M | int rate_i = (int)(AOMMAX(0.0, rate_f * num_samples) + 0.5); |
143 | 5.81M | int64_t dist_i = (int64_t)(AOMMAX(0.0, dist_f * num_samples) + 0.5); |
144 | | |
145 | | // Check if skip is better |
146 | 5.81M | if (rate_i == 0) { |
147 | 224 | dist_i = sse << 4; |
148 | 5.81M | } else if (RDCOST(x->rdmult, rate_i, dist_i) >= |
149 | 5.81M | RDCOST(x->rdmult, 0, sse << 4)) { |
150 | 15.5k | rate_i = 0; |
151 | 15.5k | dist_i = sse << 4; |
152 | 15.5k | } |
153 | | |
154 | 5.83M | if (rate) *rate = rate_i; |
155 | 5.83M | if (dist) *dist = dist_i; |
156 | 5.81M | } Unexecuted instantiation: av1_cx_iface.c:model_rd_with_curvfit Unexecuted instantiation: allintra_vis.c:model_rd_with_curvfit Unexecuted instantiation: encodeframe.c:model_rd_with_curvfit Unexecuted instantiation: encoder.c:model_rd_with_curvfit Unexecuted instantiation: encoder_utils.c:model_rd_with_curvfit Unexecuted instantiation: ethread.c:model_rd_with_curvfit Unexecuted instantiation: palette.c:model_rd_with_curvfit Unexecuted instantiation: partition_search.c:model_rd_with_curvfit rdopt.c:model_rd_with_curvfit Line | Count | Source | 121 | 97.2k | int *rate, int64_t *dist) { | 122 | 97.2k | (void)cpi; | 123 | 97.2k | (void)plane_bsize; | 124 | 97.2k | const MACROBLOCKD *const xd = &x->e_mbd; | 125 | 97.2k | const struct macroblock_plane *const p = &x->plane[plane]; | 126 | 97.2k | const int dequant_shift = (is_cur_buf_hbd(xd)) ? xd->bd - 5 : 3; | 127 | 97.2k | const int qstep = AOMMAX(p->dequant_QTX[1] >> dequant_shift, 1); | 128 | | | 129 | 97.2k | if (sse == 0) { | 130 | 0 | if (rate) *rate = 0; | 131 | 0 | if (dist) *dist = 0; | 132 | 0 | return; | 133 | 0 | } | 134 | 97.2k | const double sse_norm = (double)sse / num_samples; | 135 | 97.2k | const double qstepsqr = (double)qstep * qstep; | 136 | 97.2k | const double xqr = log2(sse_norm / qstepsqr); | 137 | 97.2k | double rate_f, dist_by_sse_norm_f; | 138 | 97.2k | av1_model_rd_curvfit(plane_bsize, sse_norm, xqr, &rate_f, | 139 | 97.2k | &dist_by_sse_norm_f); | 140 | | | 141 | 97.2k | const double dist_f = dist_by_sse_norm_f * sse_norm; | 142 | 97.2k | int rate_i = (int)(AOMMAX(0.0, rate_f * num_samples) + 0.5); | 143 | 97.2k | int64_t dist_i = (int64_t)(AOMMAX(0.0, dist_f * num_samples) + 0.5); | 144 | | | 145 | | // Check if skip is better | 146 | 97.2k | if (rate_i == 0) { | 147 | 0 | dist_i = sse << 4; | 148 | 97.2k | } else if (RDCOST(x->rdmult, rate_i, dist_i) >= | 149 | 97.2k | RDCOST(x->rdmult, 0, sse << 4)) { | 150 | 1.08k | rate_i = 0; | 151 | 1.08k | dist_i = sse << 4; | 152 | 1.08k | } | 153 | | | 154 | 97.2k | if (rate) *rate = rate_i; | 155 | 97.2k | if (dist) *dist = dist_i; | 156 | 97.2k | } |
nonrd_pickmode.c:model_rd_with_curvfit Line | Count | Source | 121 | 2.17M | int *rate, int64_t *dist) { | 122 | 2.17M | (void)cpi; | 123 | 2.17M | (void)plane_bsize; | 124 | 2.17M | const MACROBLOCKD *const xd = &x->e_mbd; | 125 | 2.17M | const struct macroblock_plane *const p = &x->plane[plane]; | 126 | 2.17M | const int dequant_shift = (is_cur_buf_hbd(xd)) ? xd->bd - 5 : 3; | 127 | 2.17M | const int qstep = AOMMAX(p->dequant_QTX[1] >> dequant_shift, 1); | 128 | | | 129 | 2.17M | if (sse == 0) { | 130 | 32 | if (rate) *rate = 0; | 131 | 32 | if (dist) *dist = 0; | 132 | 32 | return; | 133 | 32 | } | 134 | 2.17M | const double sse_norm = (double)sse / num_samples; | 135 | 2.17M | const double qstepsqr = (double)qstep * qstep; | 136 | 2.17M | const double xqr = log2(sse_norm / qstepsqr); | 137 | 2.17M | double rate_f, dist_by_sse_norm_f; | 138 | 2.17M | av1_model_rd_curvfit(plane_bsize, sse_norm, xqr, &rate_f, | 139 | 2.17M | &dist_by_sse_norm_f); | 140 | | | 141 | 2.17M | const double dist_f = dist_by_sse_norm_f * sse_norm; | 142 | 2.17M | int rate_i = (int)(AOMMAX(0.0, rate_f * num_samples) + 0.5); | 143 | 2.17M | int64_t dist_i = (int64_t)(AOMMAX(0.0, dist_f * num_samples) + 0.5); | 144 | | | 145 | | // Check if skip is better | 146 | 2.17M | if (rate_i == 0) { | 147 | 64 | dist_i = sse << 4; | 148 | 2.17M | } else if (RDCOST(x->rdmult, rate_i, dist_i) >= | 149 | 2.17M | RDCOST(x->rdmult, 0, sse << 4)) { | 150 | 2.84k | rate_i = 0; | 151 | 2.84k | dist_i = sse << 4; | 152 | 2.84k | } | 153 | | | 154 | 2.19M | if (rate) *rate = rate_i; | 155 | 2.19M | if (dist) *dist = dist_i; | 156 | 2.17M | } |
Unexecuted instantiation: superres_scale.c:model_rd_with_curvfit Unexecuted instantiation: svc_layercontext.c:model_rd_with_curvfit Unexecuted instantiation: temporal_filter.c:model_rd_with_curvfit Unexecuted instantiation: tx_search.c:model_rd_with_curvfit Unexecuted instantiation: intra_mode_search.c:model_rd_with_curvfit Unexecuted instantiation: compound_type.c:model_rd_with_curvfit Unexecuted instantiation: encode_strategy.c:model_rd_with_curvfit interp_search.c:model_rd_with_curvfit Line | Count | Source | 121 | 3.54M | int *rate, int64_t *dist) { | 122 | 3.54M | (void)cpi; | 123 | 3.54M | (void)plane_bsize; | 124 | 3.54M | const MACROBLOCKD *const xd = &x->e_mbd; | 125 | 3.54M | const struct macroblock_plane *const p = &x->plane[plane]; | 126 | 3.54M | const int dequant_shift = (is_cur_buf_hbd(xd)) ? xd->bd - 5 : 3; | 127 | 3.54M | const int qstep = AOMMAX(p->dequant_QTX[1] >> dequant_shift, 1); | 128 | | | 129 | 3.54M | if (sse == 0) { | 130 | 163 | if (rate) *rate = 0; | 131 | 163 | if (dist) *dist = 0; | 132 | 163 | return; | 133 | 163 | } | 134 | 3.54M | const double sse_norm = (double)sse / num_samples; | 135 | 3.54M | const double qstepsqr = (double)qstep * qstep; | 136 | 3.54M | const double xqr = log2(sse_norm / qstepsqr); | 137 | 3.54M | double rate_f, dist_by_sse_norm_f; | 138 | 3.54M | av1_model_rd_curvfit(plane_bsize, sse_norm, xqr, &rate_f, | 139 | 3.54M | &dist_by_sse_norm_f); | 140 | | | 141 | 3.54M | const double dist_f = dist_by_sse_norm_f * sse_norm; | 142 | 3.54M | int rate_i = (int)(AOMMAX(0.0, rate_f * num_samples) + 0.5); | 143 | 3.54M | int64_t dist_i = (int64_t)(AOMMAX(0.0, dist_f * num_samples) + 0.5); | 144 | | | 145 | | // Check if skip is better | 146 | 3.54M | if (rate_i == 0) { | 147 | 160 | dist_i = sse << 4; | 148 | 3.54M | } else if (RDCOST(x->rdmult, rate_i, dist_i) >= | 149 | 3.54M | RDCOST(x->rdmult, 0, sse << 4)) { | 150 | 11.5k | rate_i = 0; | 151 | 11.5k | dist_i = sse << 4; | 152 | 11.5k | } | 153 | | | 154 | 3.54M | if (rate) *rate = rate_i; | 155 | 3.54M | if (dist) *dist = dist_i; | 156 | 3.54M | } |
|
157 | | |
158 | | static inline void model_rd_for_sb(const AV1_COMP *const cpi, BLOCK_SIZE bsize, |
159 | | MACROBLOCK *x, MACROBLOCKD *xd, |
160 | | int plane_from, int plane_to, |
161 | | int *out_rate_sum, int64_t *out_dist_sum, |
162 | | uint8_t *skip_txfm_sb, int64_t *skip_sse_sb, |
163 | | int *plane_rate, int64_t *plane_sse, |
164 | 0 | int64_t *plane_dist) { |
165 | | // Note our transform coeffs are 8 times an orthogonal transform. |
166 | | // Hence quantizer step is also 8 times. To get effective quantizer |
167 | | // we need to divide by 8 before sending to modeling function. |
168 | 0 | int plane; |
169 | 0 | const int ref = xd->mi[0]->ref_frame[0]; |
170 | |
|
171 | 0 | int64_t rate_sum = 0; |
172 | 0 | int64_t dist_sum = 0; |
173 | 0 | int64_t total_sse = 0; |
174 | |
|
175 | 0 | assert(bsize < BLOCK_SIZES_ALL); |
176 | |
|
177 | 0 | for (plane = plane_from; plane <= plane_to; ++plane) { |
178 | 0 | if (plane && !xd->is_chroma_ref) break; |
179 | 0 | struct macroblock_plane *const p = &x->plane[plane]; |
180 | 0 | struct macroblockd_plane *const pd = &xd->plane[plane]; |
181 | 0 | const BLOCK_SIZE plane_bsize = |
182 | 0 | get_plane_block_size(bsize, pd->subsampling_x, pd->subsampling_y); |
183 | 0 | assert(plane_bsize < BLOCK_SIZES_ALL); |
184 | 0 | const int bw = block_size_wide[plane_bsize]; |
185 | 0 | const int bh = block_size_high[plane_bsize]; |
186 | 0 | int64_t sse; |
187 | 0 | int rate; |
188 | 0 | int64_t dist; |
189 | |
|
190 | 0 | sse = calculate_sse(xd, p, pd, bw, bh); |
191 | |
|
192 | 0 | model_rd_from_sse(cpi, x, plane_bsize, plane, sse, bw * bh, &rate, &dist); |
193 | |
|
194 | 0 | if (plane == 0) x->pred_sse[ref] = (unsigned int)AOMMIN(sse, UINT_MAX); |
195 | |
|
196 | 0 | total_sse += sse; |
197 | 0 | rate_sum += rate; |
198 | 0 | dist_sum += dist; |
199 | 0 | if (plane_rate) plane_rate[plane] = rate; |
200 | 0 | if (plane_sse) plane_sse[plane] = sse; |
201 | 0 | if (plane_dist) plane_dist[plane] = dist; |
202 | 0 | assert(rate_sum >= 0); |
203 | 0 | } |
204 | |
|
205 | 0 | if (skip_txfm_sb) *skip_txfm_sb = total_sse == 0; |
206 | 0 | if (skip_sse_sb) *skip_sse_sb = total_sse << 4; |
207 | 0 | rate_sum = AOMMIN(rate_sum, INT_MAX); |
208 | 0 | *out_rate_sum = (int)rate_sum; |
209 | 0 | *out_dist_sum = dist_sum; |
210 | 0 | } Unexecuted instantiation: av1_cx_iface.c:model_rd_for_sb Unexecuted instantiation: allintra_vis.c:model_rd_for_sb Unexecuted instantiation: encodeframe.c:model_rd_for_sb Unexecuted instantiation: encoder.c:model_rd_for_sb Unexecuted instantiation: encoder_utils.c:model_rd_for_sb Unexecuted instantiation: ethread.c:model_rd_for_sb Unexecuted instantiation: palette.c:model_rd_for_sb Unexecuted instantiation: partition_search.c:model_rd_for_sb Unexecuted instantiation: rdopt.c:model_rd_for_sb Unexecuted instantiation: nonrd_pickmode.c:model_rd_for_sb Unexecuted instantiation: superres_scale.c:model_rd_for_sb Unexecuted instantiation: svc_layercontext.c:model_rd_for_sb Unexecuted instantiation: temporal_filter.c:model_rd_for_sb Unexecuted instantiation: tx_search.c:model_rd_for_sb Unexecuted instantiation: intra_mode_search.c:model_rd_for_sb Unexecuted instantiation: compound_type.c:model_rd_for_sb Unexecuted instantiation: encode_strategy.c:model_rd_for_sb Unexecuted instantiation: interp_search.c:model_rd_for_sb |
211 | | |
212 | | static inline void model_rd_for_sb_with_curvfit( |
213 | | const AV1_COMP *const cpi, BLOCK_SIZE bsize, MACROBLOCK *x, MACROBLOCKD *xd, |
214 | | int plane_from, int plane_to, int *out_rate_sum, int64_t *out_dist_sum, |
215 | | uint8_t *skip_txfm_sb, int64_t *skip_sse_sb, int *plane_rate, |
216 | 2.94M | int64_t *plane_sse, int64_t *plane_dist) { |
217 | | // Note our transform coeffs are 8 times an orthogonal transform. |
218 | | // Hence quantizer step is also 8 times. To get effective quantizer |
219 | | // we need to divide by 8 before sending to modeling function. |
220 | 2.94M | const int ref = xd->mi[0]->ref_frame[0]; |
221 | | |
222 | 2.94M | int64_t rate_sum = 0; |
223 | 2.94M | int64_t dist_sum = 0; |
224 | 2.94M | int64_t total_sse = 0; |
225 | | |
226 | 6.58M | for (int plane = plane_from; plane <= plane_to; ++plane) { |
227 | 3.64M | if (plane && !xd->is_chroma_ref) break; |
228 | 3.64M | struct macroblockd_plane *const pd = &xd->plane[plane]; |
229 | 3.64M | const BLOCK_SIZE plane_bsize = |
230 | 3.64M | get_plane_block_size(bsize, pd->subsampling_x, pd->subsampling_y); |
231 | 3.64M | int64_t dist, sse; |
232 | 3.64M | int rate; |
233 | 3.64M | int bw, bh; |
234 | 3.64M | const struct macroblock_plane *const p = &x->plane[plane]; |
235 | 3.64M | get_txb_dimensions(xd, plane, plane_bsize, 0, 0, plane_bsize, NULL, NULL, |
236 | 3.64M | &bw, &bh); |
237 | | |
238 | 3.64M | sse = calculate_sse(xd, p, pd, bw, bh); |
239 | 3.64M | model_rd_with_curvfit(cpi, x, plane_bsize, plane, sse, bw * bh, &rate, |
240 | 3.64M | &dist); |
241 | | |
242 | 3.64M | if (plane == 0) x->pred_sse[ref] = (unsigned int)AOMMIN(sse, UINT_MAX); |
243 | | |
244 | 3.64M | total_sse += sse; |
245 | 3.64M | rate_sum += rate; |
246 | 3.64M | dist_sum += dist; |
247 | | |
248 | 3.64M | if (plane_rate) plane_rate[plane] = rate; |
249 | 3.64M | if (plane_sse) plane_sse[plane] = sse; |
250 | 3.64M | if (plane_dist) plane_dist[plane] = dist; |
251 | 3.64M | } |
252 | | |
253 | 2.94M | if (skip_txfm_sb) *skip_txfm_sb = rate_sum == 0; |
254 | 2.94M | if (skip_sse_sb) *skip_sse_sb = total_sse << 4; |
255 | 2.94M | *out_rate_sum = (int)rate_sum; |
256 | 2.94M | *out_dist_sum = dist_sum; |
257 | 2.94M | } Unexecuted instantiation: av1_cx_iface.c:model_rd_for_sb_with_curvfit Unexecuted instantiation: allintra_vis.c:model_rd_for_sb_with_curvfit Unexecuted instantiation: encodeframe.c:model_rd_for_sb_with_curvfit Unexecuted instantiation: encoder.c:model_rd_for_sb_with_curvfit Unexecuted instantiation: encoder_utils.c:model_rd_for_sb_with_curvfit Unexecuted instantiation: ethread.c:model_rd_for_sb_with_curvfit Unexecuted instantiation: palette.c:model_rd_for_sb_with_curvfit Unexecuted instantiation: partition_search.c:model_rd_for_sb_with_curvfit rdopt.c:model_rd_for_sb_with_curvfit Line | Count | Source | 216 | 55.5k | int64_t *plane_sse, int64_t *plane_dist) { | 217 | | // Note our transform coeffs are 8 times an orthogonal transform. | 218 | | // Hence quantizer step is also 8 times. To get effective quantizer | 219 | | // we need to divide by 8 before sending to modeling function. | 220 | 55.5k | const int ref = xd->mi[0]->ref_frame[0]; | 221 | | | 222 | 55.5k | int64_t rate_sum = 0; | 223 | 55.5k | int64_t dist_sum = 0; | 224 | 55.5k | int64_t total_sse = 0; | 225 | | | 226 | 152k | for (int plane = plane_from; plane <= plane_to; ++plane) { | 227 | 97.1k | if (plane && !xd->is_chroma_ref) break; | 228 | 97.1k | struct macroblockd_plane *const pd = &xd->plane[plane]; | 229 | 97.1k | const BLOCK_SIZE plane_bsize = | 230 | 97.1k | get_plane_block_size(bsize, pd->subsampling_x, pd->subsampling_y); | 231 | 97.1k | int64_t dist, sse; | 232 | 97.1k | int rate; | 233 | 97.1k | int bw, bh; | 234 | 97.1k | const struct macroblock_plane *const p = &x->plane[plane]; | 235 | 97.1k | get_txb_dimensions(xd, plane, plane_bsize, 0, 0, plane_bsize, NULL, NULL, | 236 | 97.1k | &bw, &bh); | 237 | | | 238 | 97.1k | sse = calculate_sse(xd, p, pd, bw, bh); | 239 | 97.1k | model_rd_with_curvfit(cpi, x, plane_bsize, plane, sse, bw * bh, &rate, | 240 | 97.1k | &dist); | 241 | | | 242 | 97.1k | if (plane == 0) x->pred_sse[ref] = (unsigned int)AOMMIN(sse, UINT_MAX); | 243 | | | 244 | 97.1k | total_sse += sse; | 245 | 97.1k | rate_sum += rate; | 246 | 97.1k | dist_sum += dist; | 247 | | | 248 | 97.1k | if (plane_rate) plane_rate[plane] = rate; | 249 | 97.1k | if (plane_sse) plane_sse[plane] = sse; | 250 | 97.1k | if (plane_dist) plane_dist[plane] = dist; | 251 | 97.1k | } | 252 | | | 253 | 55.5k | if (skip_txfm_sb) *skip_txfm_sb = rate_sum == 0; | 254 | 55.5k | if (skip_sse_sb) *skip_sse_sb = total_sse << 4; | 255 | 55.5k | *out_rate_sum = (int)rate_sum; | 256 | 55.5k | *out_dist_sum = dist_sum; | 257 | 55.5k | } |
Unexecuted instantiation: nonrd_pickmode.c:model_rd_for_sb_with_curvfit Unexecuted instantiation: superres_scale.c:model_rd_for_sb_with_curvfit Unexecuted instantiation: svc_layercontext.c:model_rd_for_sb_with_curvfit Unexecuted instantiation: temporal_filter.c:model_rd_for_sb_with_curvfit Unexecuted instantiation: tx_search.c:model_rd_for_sb_with_curvfit Unexecuted instantiation: intra_mode_search.c:model_rd_for_sb_with_curvfit Unexecuted instantiation: compound_type.c:model_rd_for_sb_with_curvfit Unexecuted instantiation: encode_strategy.c:model_rd_for_sb_with_curvfit interp_search.c:model_rd_for_sb_with_curvfit Line | Count | Source | 216 | 2.89M | int64_t *plane_sse, int64_t *plane_dist) { | 217 | | // Note our transform coeffs are 8 times an orthogonal transform. | 218 | | // Hence quantizer step is also 8 times. To get effective quantizer | 219 | | // we need to divide by 8 before sending to modeling function. | 220 | 2.89M | const int ref = xd->mi[0]->ref_frame[0]; | 221 | | | 222 | 2.89M | int64_t rate_sum = 0; | 223 | 2.89M | int64_t dist_sum = 0; | 224 | 2.89M | int64_t total_sse = 0; | 225 | | | 226 | 6.43M | for (int plane = plane_from; plane <= plane_to; ++plane) { | 227 | 3.54M | if (plane && !xd->is_chroma_ref) break; | 228 | 3.54M | struct macroblockd_plane *const pd = &xd->plane[plane]; | 229 | 3.54M | const BLOCK_SIZE plane_bsize = | 230 | 3.54M | get_plane_block_size(bsize, pd->subsampling_x, pd->subsampling_y); | 231 | 3.54M | int64_t dist, sse; | 232 | 3.54M | int rate; | 233 | 3.54M | int bw, bh; | 234 | 3.54M | const struct macroblock_plane *const p = &x->plane[plane]; | 235 | 3.54M | get_txb_dimensions(xd, plane, plane_bsize, 0, 0, plane_bsize, NULL, NULL, | 236 | 3.54M | &bw, &bh); | 237 | | | 238 | 3.54M | sse = calculate_sse(xd, p, pd, bw, bh); | 239 | 3.54M | model_rd_with_curvfit(cpi, x, plane_bsize, plane, sse, bw * bh, &rate, | 240 | 3.54M | &dist); | 241 | | | 242 | 3.54M | if (plane == 0) x->pred_sse[ref] = (unsigned int)AOMMIN(sse, UINT_MAX); | 243 | | | 244 | 3.54M | total_sse += sse; | 245 | 3.54M | rate_sum += rate; | 246 | 3.54M | dist_sum += dist; | 247 | | | 248 | 3.54M | if (plane_rate) plane_rate[plane] = rate; | 249 | 3.54M | if (plane_sse) plane_sse[plane] = sse; | 250 | 3.54M | if (plane_dist) plane_dist[plane] = dist; | 251 | 3.54M | } | 252 | | | 253 | 2.89M | if (skip_txfm_sb) *skip_txfm_sb = rate_sum == 0; | 254 | 2.89M | if (skip_sse_sb) *skip_sse_sb = total_sse << 4; | 255 | 2.89M | *out_rate_sum = (int)rate_sum; | 256 | 2.89M | *out_dist_sum = dist_sum; | 257 | 2.89M | } |
|
258 | | |
259 | | enum { MODELRD_LEGACY, MODELRD_CURVFIT, MODELRD_TYPES } UENUM1BYTE(ModelRdType); |
260 | | |
261 | | static const model_rd_for_sb_type model_rd_sb_fn[MODELRD_TYPES] = { |
262 | | model_rd_for_sb, model_rd_for_sb_with_curvfit |
263 | | }; |
264 | | |
265 | | static const model_rd_from_sse_type model_rd_sse_fn[MODELRD_TYPES] = { |
266 | | model_rd_from_sse, model_rd_with_curvfit |
267 | | }; |
268 | | |
269 | | #ifdef __cplusplus |
270 | | } // extern "C" |
271 | | #endif |
272 | | #endif // AOM_AV1_ENCODER_MODEL_RD_H_ |