2014-01-20 14:34:11 +00:00
|
|
|
#ifndef RDO_H_
|
|
|
|
#define RDO_H_
|
2014-01-27 12:39:56 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* This file is part of Kvazaar HEVC encoder.
|
2014-02-21 13:00:20 +00:00
|
|
|
*
|
2015-02-23 11:18:48 +00:00
|
|
|
* Copyright (C) 2013-2015 Tampere University of Technology and others (see
|
2014-01-27 12:39:56 +00:00
|
|
|
* COPYING file).
|
|
|
|
*
|
2015-02-23 11:18:48 +00:00
|
|
|
* Kvazaar is free software: you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU Lesser General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2.1 of the License, or (at your
|
|
|
|
* option) any later version.
|
2014-01-27 12:39:56 +00:00
|
|
|
*
|
2015-02-23 11:18:48 +00:00
|
|
|
* Kvazaar is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
|
|
|
* more details.
|
2014-01-27 12:39:56 +00:00
|
|
|
*
|
2015-02-23 11:18:48 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with Kvazaar. If not, see <http://www.gnu.org/licenses/>.
|
2014-01-27 12:39:56 +00:00
|
|
|
****************************************************************************/
|
|
|
|
|
2015-12-17 11:42:57 +00:00
|
|
|
/**
|
|
|
|
* \ingroup Compression
|
2014-01-20 14:34:11 +00:00
|
|
|
* \file
|
2015-12-17 11:42:57 +00:00
|
|
|
* Rate-Distortion Optimization related functionality.
|
2014-01-20 14:34:11 +00:00
|
|
|
*/
|
|
|
|
|
2016-04-01 14:14:23 +00:00
|
|
|
#include "cabac.h"
|
|
|
|
#include "cu.h"
|
2014-06-03 11:51:30 +00:00
|
|
|
#include "encoderstate.h"
|
2016-04-01 14:14:23 +00:00
|
|
|
#include "global.h" // IWYU pragma: keep
|
2016-06-20 03:30:41 +00:00
|
|
|
#include "search_inter.h"
|
2014-01-20 14:34:11 +00:00
|
|
|
|
|
|
|
|
2015-08-26 08:50:27 +00:00
|
|
|
extern const uint32_t kvz_g_go_rice_range[5];
|
|
|
|
extern const uint32_t kvz_g_go_rice_prefix_len[5];
|
2014-01-20 14:34:11 +00:00
|
|
|
|
2015-08-26 08:50:27 +00:00
|
|
|
void kvz_rdoq(encoder_state_t *state, coeff_t *coef, coeff_t *dest_coeff, int32_t width,
|
2014-05-13 12:08:34 +00:00
|
|
|
int32_t height, int8_t type, int8_t scan_mode, int8_t block_type, int8_t tr_depth);
|
2014-01-20 14:34:11 +00:00
|
|
|
|
2015-08-26 08:50:27 +00:00
|
|
|
int32_t kvz_get_coeff_cost(const encoder_state_t *state, coeff_t *coeff, int32_t width, int32_t type, int8_t scan_mode);
|
2014-01-20 14:34:11 +00:00
|
|
|
|
2015-08-26 08:50:27 +00:00
|
|
|
int32_t kvz_get_ic_rate(encoder_state_t *state, uint32_t abs_level, uint16_t ctx_num_one, uint16_t ctx_num_abs,
|
2015-03-04 15:00:23 +00:00
|
|
|
uint16_t abs_go_rice, uint32_t c1_idx, uint32_t c2_idx, int8_t type);
|
2015-08-26 08:50:27 +00:00
|
|
|
uint32_t kvz_get_coded_level(encoder_state_t * state, double* coded_cost, double* coded_cost0, double* coded_cost_sig,
|
2015-03-04 15:00:23 +00:00
|
|
|
int32_t level_double, uint32_t max_abs_level,
|
|
|
|
uint16_t ctx_num_sig, uint16_t ctx_num_one, uint16_t ctx_num_abs,
|
|
|
|
uint16_t abs_go_rice,
|
|
|
|
uint32_t c1_idx, uint32_t c2_idx,
|
|
|
|
int32_t q_bits,double temp, int8_t last, int8_t type);
|
2014-01-20 14:34:11 +00:00
|
|
|
|
2016-06-20 03:30:41 +00:00
|
|
|
kvz_mvd_cost_func kvz_calc_mvd_cost_cabac;
|
|
|
|
|
2016-08-29 20:44:41 +00:00
|
|
|
uint32_t kvz_get_mvd_coding_cost_cabac(encoder_state_t * const state, vector2d_t *mvd, const cabac_data_t* cabac);
|
2015-08-21 06:11:30 +00:00
|
|
|
|
2017-01-18 15:58:50 +00:00
|
|
|
// Number of fixed point fractional bits used in the fractional bit table.
|
|
|
|
#define CTX_FRAC_BITS 15
|
|
|
|
#define CTX_FRAC_ONE_BIT (1 << CTX_FRAC_BITS)
|
|
|
|
#define CTX_FRAC_HALF_BIT (1 << (CTX_FRAC_BITS - 1))
|
|
|
|
|
2016-08-30 15:12:14 +00:00
|
|
|
extern const uint32_t kvz_entropy_bits[128];
|
|
|
|
#define CTX_ENTROPY_BITS(ctx, val) kvz_entropy_bits[(ctx)->uc_state ^ (val)]
|
|
|
|
|
|
|
|
// Floating point fractional bits, derived from kvz_entropy_bits
|
2015-09-16 06:30:46 +00:00
|
|
|
extern const float kvz_f_entropy_bits[128];
|
2016-08-30 15:12:14 +00:00
|
|
|
#define CTX_ENTROPY_FBITS(ctx, val) kvz_f_entropy_bits[(ctx)->uc_state ^ (val)]
|
2014-01-20 14:34:11 +00:00
|
|
|
|
|
|
|
#endif
|