2014-01-20 14:34:11 +00:00
|
|
|
#ifndef RDO_H_
|
|
|
|
#define RDO_H_
|
2014-01-27 12:39:56 +00:00
|
|
|
/*****************************************************************************
|
2021-11-23 06:46:06 +00:00
|
|
|
* This file is part of uvg266 VVC encoder.
|
2014-02-21 13:00:20 +00:00
|
|
|
*
|
2021-10-07 08:32:59 +00:00
|
|
|
* Copyright (c) 2021, Tampere University, ITU/ISO/IEC, project contributors
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
* are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright notice, this
|
|
|
|
* list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright notice, this
|
|
|
|
* list of conditions and the following disclaimer in the documentation and/or
|
|
|
|
* other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON
|
|
|
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
* INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
|
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
|
|
|
|
2023-01-05 12:21:43 +00:00
|
|
|
#define QUANT_SHIFT 14
|
|
|
|
#define IQUANT_SHIFT 6
|
2014-01-20 14:34:11 +00:00
|
|
|
|
2022-04-28 11:18:09 +00:00
|
|
|
extern const uint32_t uvg_g_go_rice_range[5];
|
|
|
|
extern const uint32_t uvg_g_go_rice_prefix_len[5];
|
2014-01-20 14:34:11 +00:00
|
|
|
|
2022-04-28 11:18:09 +00:00
|
|
|
int uvg_init_rdcost_outfiles(const char *fn_template);
|
|
|
|
void uvg_close_rdcost_outfiles(void);
|
2020-11-05 17:47:47 +00:00
|
|
|
|
2022-06-29 13:25:25 +00:00
|
|
|
void uvg_rdoq(
|
|
|
|
encoder_state_t *state,
|
|
|
|
coeff_t *coef,
|
|
|
|
coeff_t *dest_coeff,
|
|
|
|
int32_t width,
|
|
|
|
int32_t height,
|
|
|
|
int8_t type,
|
|
|
|
int8_t scan_mode,
|
|
|
|
int8_t block_type,
|
|
|
|
uint16_t cbf,
|
2023-09-26 08:47:34 +00:00
|
|
|
uint8_t lfnst_idx, uint8_t mts_idx);
|
2014-01-20 14:34:11 +00:00
|
|
|
|
2021-04-30 10:44:42 +00:00
|
|
|
|
2022-04-28 11:18:09 +00:00
|
|
|
int uvg_ts_rdoq(encoder_state_t* const state, coeff_t* src_coeff, coeff_t* dest_coeff, int32_t width,
|
2021-04-30 10:44:42 +00:00
|
|
|
int32_t height, int8_t type, int8_t scan_mode);
|
|
|
|
|
|
|
|
|
2022-05-17 10:55:07 +00:00
|
|
|
double uvg_get_coeff_cost(
|
|
|
|
const encoder_state_t * const state,
|
|
|
|
const coeff_t *coeff,
|
|
|
|
cu_info_t* cur_tu,
|
2022-09-08 12:10:54 +00:00
|
|
|
const cu_loc_t* const cu_loc,
|
2022-05-25 10:47:02 +00:00
|
|
|
color_t color,
|
2022-05-17 10:55:07 +00:00
|
|
|
int8_t scan_mode,
|
2022-08-31 10:53:17 +00:00
|
|
|
int8_t tr_skip,
|
|
|
|
int coeff_order);
|
2014-01-20 14:34:11 +00:00
|
|
|
|
2022-04-28 11:18:09 +00:00
|
|
|
int32_t uvg_get_ic_rate(encoder_state_t *state, uint32_t abs_level, uint16_t ctx_num_gt1, uint16_t ctx_num_gt2, uint16_t ctx_num_par,
|
2021-03-30 07:19:35 +00:00
|
|
|
uint16_t abs_go_rice, uint32_t reg_bins, int8_t type, int use_limited_prefix_length);
|
2022-04-28 11:18:09 +00:00
|
|
|
uint32_t uvg_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,
|
2021-02-25 11:18:57 +00:00
|
|
|
uint16_t ctx_num_sig, uint16_t ctx_num_gt1, uint16_t ctx_num_gt2, uint16_t ctx_num_par,
|
2015-03-04 15:00:23 +00:00
|
|
|
uint16_t abs_go_rice,
|
2021-02-26 14:41:54 +00:00
|
|
|
uint32_t reg_bins,
|
2015-03-04 15:00:23 +00:00
|
|
|
int32_t q_bits,double temp, int8_t last, int8_t type);
|
2014-01-20 14:34:11 +00:00
|
|
|
|
2022-04-28 11:18:09 +00:00
|
|
|
uvg_mvd_cost_func uvg_calc_mvd_cost_cabac;
|
2022-07-08 15:14:25 +00:00
|
|
|
uvg_mvd_cost_func uvg_calc_ibc_mvd_cost_cabac;
|
2016-06-20 03:30:41 +00:00
|
|
|
|
2022-05-30 09:11:48 +00:00
|
|
|
double uvg_get_mvd_coding_cost_cabac(const encoder_state_t* state,
|
2021-12-16 06:40:23 +00:00
|
|
|
const cabac_data_t* cabac,
|
|
|
|
int32_t mvd_hor,
|
|
|
|
int32_t mvd_ver);
|
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))
|
|
|
|
|
2022-04-28 11:18:09 +00:00
|
|
|
extern const uint32_t uvg_entropy_bits[512];
|
|
|
|
#define CTX_ENTROPY_BITS(ctx, val) uvg_entropy_bits[(CTX_STATE(ctx)<<1) ^ (val)]
|
2016-08-30 15:12:14 +00:00
|
|
|
|
2014-01-20 14:34:11 +00:00
|
|
|
|
|
|
|
#endif
|