2019-11-20 06:38:33 +00:00
|
|
|
#pragma once
|
2014-01-24 10:37:15 +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-24 10:37:15 +00:00
|
|
|
****************************************************************************/
|
|
|
|
|
2015-12-17 11:42:57 +00:00
|
|
|
/**
|
|
|
|
* \ingroup Reconstruction
|
|
|
|
* \file
|
|
|
|
* Intra prediction.
|
|
|
|
*/
|
2012-06-11 15:43:29 +00:00
|
|
|
|
2016-04-01 14:14:23 +00:00
|
|
|
#include "cu.h"
|
|
|
|
#include "encoderstate.h"
|
2016-03-30 09:41:37 +00:00
|
|
|
#include "global.h" // IWYU pragma: keep
|
2022-04-28 11:26:05 +00:00
|
|
|
#include "uvg266.h"
|
2013-09-18 09:16:03 +00:00
|
|
|
|
2022-02-04 12:18:48 +00:00
|
|
|
// Maximum possible reference line length for intra blocks
|
|
|
|
#define INTRA_REF_LENGTH (2 * 128 + 3 + 33 * MAX_REF_LINE_IDX)
|
|
|
|
|
2015-10-03 00:36:58 +00:00
|
|
|
typedef struct {
|
2022-04-28 11:18:09 +00:00
|
|
|
uvg_pixel left[INTRA_REF_LENGTH];
|
|
|
|
uvg_pixel top[INTRA_REF_LENGTH];
|
|
|
|
} uvg_intra_ref;
|
2015-10-03 00:36:58 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2022-04-28 11:18:09 +00:00
|
|
|
uvg_intra_ref ref;
|
|
|
|
uvg_intra_ref filtered_ref;
|
2015-10-03 00:36:58 +00:00
|
|
|
bool filtered_initialized;
|
2022-04-28 11:18:09 +00:00
|
|
|
} uvg_intra_references;
|
2015-10-03 00:36:58 +00:00
|
|
|
|
2021-11-17 09:19:55 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int16_t a;
|
|
|
|
int16_t shift;
|
|
|
|
int16_t b;
|
|
|
|
} cclm_parameters_t;
|
2015-10-05 03:18:20 +00:00
|
|
|
|
2022-04-08 05:53:11 +00:00
|
|
|
typedef struct {
|
|
|
|
cu_info_t pred_cu;
|
|
|
|
cclm_parameters_t cclm_parameters[2];
|
|
|
|
double cost;
|
|
|
|
double bits;
|
|
|
|
double coeff_bits;
|
|
|
|
double distortion;
|
2022-06-14 07:41:58 +00:00
|
|
|
double lfnst_costs[3];
|
2022-04-08 05:53:11 +00:00
|
|
|
} intra_search_data_t ;
|
|
|
|
|
2022-04-12 05:39:30 +00:00
|
|
|
|
2022-05-30 09:11:48 +00:00
|
|
|
#define UVG_NUM_INTRA_MODES 67
|
2022-04-12 05:39:30 +00:00
|
|
|
|
2015-10-05 03:18:20 +00:00
|
|
|
/**
|
|
|
|
* \brief Function for deriving intra luma predictions
|
2016-01-15 08:51:40 +00:00
|
|
|
* \param x x-coordinate of the PU in pixels
|
|
|
|
* \param y y-coordinate of the PU in pixels
|
|
|
|
* \param preds output buffer for 3 predictions
|
|
|
|
* \param cur_pu PU to check
|
|
|
|
* \param left_pu PU to the left of cur_pu
|
|
|
|
* \param above_pu PU above cur_pu
|
|
|
|
* \returns 1 if predictions are found, otherwise 0
|
2015-10-05 03:18:20 +00:00
|
|
|
*/
|
2022-04-28 11:18:09 +00:00
|
|
|
int8_t uvg_intra_get_dir_luma_predictor(
|
2015-10-05 03:18:20 +00:00
|
|
|
const uint32_t x,
|
|
|
|
const uint32_t y,
|
|
|
|
int8_t *preds,
|
2016-01-15 08:51:40 +00:00
|
|
|
const cu_info_t *const cur_pu,
|
|
|
|
const cu_info_t *const left_pu,
|
|
|
|
const cu_info_t *const above_pu);
|
2013-03-13 13:56:43 +00:00
|
|
|
|
2015-10-03 00:36:58 +00:00
|
|
|
/**
|
2021-09-15 12:19:54 +00:00
|
|
|
* \brief Build intra prediction reference buffers.
|
|
|
|
* \param log2_width Log2 of width, range 2..5.
|
|
|
|
* \param color What color pixels to use.
|
|
|
|
* \param luma_px Luma coordinates of the prediction block.
|
|
|
|
* \param pic_px Picture dimensions in luma pixels.
|
|
|
|
* \param lcu LCU struct.
|
|
|
|
* \param refs Pointer to top and left references.
|
|
|
|
* \param entropy_sync Indicate that top right is not available if WPP is enabled.
|
2021-11-09 03:58:26 +00:00
|
|
|
* \param extra_refs Additional left edge reference lines for use with MRL.
|
2021-11-19 13:12:58 +00:00
|
|
|
* \param multi_ref_idx Multi reference line index for the prediction block.
|
2015-10-03 00:36:58 +00:00
|
|
|
*/
|
2022-04-28 11:18:09 +00:00
|
|
|
void uvg_intra_build_reference(
|
2015-10-03 00:36:58 +00:00
|
|
|
const int_fast8_t log2_width,
|
|
|
|
const color_t color,
|
|
|
|
const vector2d_t *const luma_px,
|
|
|
|
const vector2d_t *const pic_px,
|
|
|
|
const lcu_t *const lcu,
|
2022-04-28 11:18:09 +00:00
|
|
|
uvg_intra_references *const refs,
|
2021-11-09 03:58:26 +00:00
|
|
|
bool entropy_sync,
|
2022-04-28 11:18:09 +00:00
|
|
|
uvg_pixel *extra_refs,
|
2021-12-06 17:12:08 +00:00
|
|
|
uint8_t multi_ref_idx);
|
2015-10-03 00:36:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Generate intra predictions.
|
2016-07-23 12:04:45 +00:00
|
|
|
* \param refs Reference pixels used for the prediction.
|
|
|
|
* \param log2_width Width of the predicted block.
|
|
|
|
* \param mode Intra mode used for the prediction.
|
|
|
|
* \param color Color of the prediction.
|
|
|
|
* \param dst Buffer for the predicted pixels.
|
|
|
|
* \param filter_boundary Whether to filter the boundary on modes 10 and 26.
|
2015-10-03 00:36:58 +00:00
|
|
|
*/
|
2022-04-28 11:18:09 +00:00
|
|
|
void uvg_intra_predict(
|
2022-04-08 05:53:11 +00:00
|
|
|
const encoder_state_t* const state,
|
2022-05-30 09:11:48 +00:00
|
|
|
uvg_intra_references* const refs,
|
2022-04-08 10:41:42 +00:00
|
|
|
const cu_loc_t* const cu_loc,
|
|
|
|
const color_t color,
|
2022-05-30 09:11:48 +00:00
|
|
|
uvg_pixel* dst,
|
2022-04-12 11:51:49 +00:00
|
|
|
const intra_search_data_t* data,
|
|
|
|
const lcu_t* lcu
|
|
|
|
);
|
2015-10-03 00:36:58 +00:00
|
|
|
|
2022-04-28 11:18:09 +00:00
|
|
|
void uvg_intra_recon_cu(
|
2022-04-12 11:51:49 +00:00
|
|
|
encoder_state_t* const state,
|
2015-10-05 03:18:20 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int depth,
|
2022-04-11 06:58:37 +00:00
|
|
|
intra_search_data_t* search_data,
|
2015-10-05 03:18:20 +00:00
|
|
|
cu_info_t *cur_cu,
|
|
|
|
lcu_t *lcu);
|
2013-02-24 14:03:40 +00:00
|
|
|
|
2022-04-28 11:18:09 +00:00
|
|
|
int uvg_get_mip_flag_context(int x, int y, int width, int height, const lcu_t* lcu, cu_array_t* const cu_a);
|