/* * Copyright (c) 2021, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License * was not distributed with this source code in the LICENSE file, you can * obtain it at www.aomedia.org/license/software. If the Alliance for Open * Media Patent License 1.0 was not distributed with this source code in the * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
// Look up table of individual cost of coefficient by its quantization level. // determined based on Laplacian distribution conditioned on estimated context staticconstint costLUT[15] = { -1143, 53, 545, 825, 1031,
1209, 1393, 1577, 1763, 1947,
2132, 2317, 2501, 2686, 2871 };
staticinline int64_t get_coeff_dist(tran_low_t tcoeff, tran_low_t dqcoeff, int shift, const qm_val_t *qmatrix, int coeff_idx) {
int64_t diff = (tcoeff - dqcoeff) * (1 << shift); if (qmatrix == NULL) { return diff * diff;
} // When AOM_DIST_METRIC_QM_PSNR is enabled, this mirrors the rate-distortion // computation done in av1_block_error_qm, improving visual quality. // The maximum value of `shift` is 2, `tcoeff` and `dqcoeff` are at most 22 // bits, and AOM_QM_BITS is 5, so `diff` should fit in 29-bits. The // multiplication `diff * diff` then does not risk overflowing.
diff *= qmatrix[coeff_idx]; const int64_t error =
(diff * diff + (1 << (2 * AOM_QM_BITS - 1))) >> (2 * AOM_QM_BITS); return error;
}
static AOM_FORCE_INLINE int get_two_coeff_cost_simple( int ci, tran_low_t abs_qc, int coeff_ctx, const LV_MAP_COEFF_COST *txb_costs, int bhl, TX_CLASS tx_class, const uint8_t *levels, int *cost_low) { // this simple version assumes the coeff's scan_idx is not DC (scan_idx != 0) // and not the last (scan_idx != eob - 1)
assert(ci > 0); int cost = txb_costs->base_cost[coeff_ctx][AOMMIN(abs_qc, 3)]; int diff = 0; if (abs_qc <= 3) diff = txb_costs->base_cost[coeff_ctx][abs_qc + 4]; if (abs_qc) {
cost += av1_cost_literal(1); if (abs_qc > NUM_BASE_LEVELS) { constint br_ctx = get_br_ctx(levels, ci, bhl, tx_class); int brcost_diff = 0;
cost += get_br_cost_with_diff(abs_qc, txb_costs->lps_cost[br_ctx],
&brcost_diff);
diff += brcost_diff;
}
}
*cost_low = cost - diff;
return cost;
}
staticinlineint get_coeff_cost_eob(int ci, tran_low_t abs_qc, int sign, int coeff_ctx, int dc_sign_ctx, const LV_MAP_COEFF_COST *txb_costs, int bhl, TX_CLASS tx_class) { int cost = 0;
cost += txb_costs->base_eob_cost[coeff_ctx][AOMMIN(abs_qc, 3) - 1]; if (abs_qc != 0) { if (ci == 0) {
cost += txb_costs->dc_sign_cost[dc_sign_ctx][sign];
} else {
cost += av1_cost_literal(1);
} if (abs_qc > NUM_BASE_LEVELS) { int br_ctx;
br_ctx = get_br_ctx_eob(ci, bhl, tx_class);
cost += get_br_cost(abs_qc, txb_costs->lps_cost[br_ctx]);
}
} return cost;
}
staticinlineint get_coeff_cost_general(int is_last, int ci, tran_low_t abs_qc, int sign, int coeff_ctx, int dc_sign_ctx, const LV_MAP_COEFF_COST *txb_costs, int bhl, TX_CLASS tx_class, const uint8_t *levels) { int cost = 0; if (is_last) {
cost += txb_costs->base_eob_cost[coeff_ctx][AOMMIN(abs_qc, 3) - 1];
} else {
cost += txb_costs->base_cost[coeff_ctx][AOMMIN(abs_qc, 3)];
} if (abs_qc != 0) { if (ci == 0) {
cost += txb_costs->dc_sign_cost[dc_sign_ctx][sign];
} else {
cost += av1_cost_literal(1);
} if (abs_qc > NUM_BASE_LEVELS) { int br_ctx; if (is_last)
br_ctx = get_br_ctx_eob(ci, bhl, tx_class); else
br_ctx = get_br_ctx(levels, ci, bhl, tx_class);
cost += get_br_cost(abs_qc, txb_costs->lps_cost[br_ctx]);
}
} return cost;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.