Added cfg variable intra_smoothing_disabled and some cleanup

This commit is contained in:
Marko Viitanen 2019-11-20 08:38:33 +02:00
parent eb2caf9118
commit 94d89f03c7
7 changed files with 25 additions and 76 deletions

View file

@ -141,6 +141,8 @@ int kvz_config_init(kvz_config *cfg)
cfg->max_merge = 5;
cfg->early_skip = true;
cfg->intra_smoothing_disabled = false;
return 1;
}

View file

@ -350,7 +350,7 @@ static void encoder_state_write_bitstream_SPS_extension(bitstream_t *stream,
WRITE_U(stream, 1, 1, "implicit_rdpcm_enabled_flag");
WRITE_U(stream, 0, 1, "explicit_rdpcm_enabled_flag");
WRITE_U(stream, 0, 1, "extended_precision_processing_flag");
WRITE_U(stream, 0, 1, "intra_smoothing_disabled_flag");
WRITE_U(stream, state->encoder_control->cfg.intra_smoothing_disabled, 1, "intra_smoothing_disabled_flag");
WRITE_U(stream, 0, 1, "high_precision_offsets_enabled_flag");
WRITE_U(stream, 0, 1, "persistent_rice_adaptation_enabled_flag");
WRITE_U(stream, 0, 1, "cabac_bypass_alignment_enabled_flag");

View file

@ -119,8 +119,6 @@ int8_t kvz_intra_get_dir_luma_predictor(
preds[5] = (left_intra_dir % mod) + 2;
}
} else { // If we have two distinct predictions
//preds[0] = left_intra_dir;
//preds[1] = above_intra_dir;
number_of_candidates = 2;
uint8_t max_cand_mode_idx = preds[0] > preds[1] ? 0 : 1;
@ -238,6 +236,7 @@ static void intra_pred_dc(
}
void kvz_intra_predict(
encoder_state_t *const state,
kvz_intra_references *refs,
int_fast8_t log2_width,
int_fast8_t mode,
@ -246,9 +245,10 @@ void kvz_intra_predict(
bool filter_boundary)
{
const int_fast8_t width = 1 << log2_width;
const kvz_config *cfg = &state->encoder_control->cfg;
const kvz_intra_ref *used_ref = &refs->ref;
if (color != COLOR_Y || mode == 1 || width == 4) {
if (cfg->intra_smoothing_disabled || color != COLOR_Y || mode == 1 || width == 4) {
// For chroma, DC and 4x4 blocks, always use unfiltered reference.
} else if (mode == 0) {
// Otherwise, use filtered for planar.
@ -284,8 +284,8 @@ void kvz_intra_predict(
}
// pdpc
bool pdpcCondition = (mode == 0 || mode == 1 || mode == 18 || mode == 50);
if (pdpcCondition)
//bool pdpcCondition = (mode == 0 || mode == 1 || mode == 18 || mode == 50);
//if (pdpcCondition)
{
// TODO: replace latter log2_width with log2_height
const int scale = ((log2_width - 2 + log2_width - 2 + 2) >> 2);
@ -300,42 +300,7 @@ void kvz_intra_predict(
+ wT * (used_ref->top[x + 1] - dst[x + y * width]) + 32) >> 6);
}
}
}
//else if (mode == 1) { // DC
// for (int y = 0; y < width; y++) {
// int wT = 32 >> MIN(31, ((y << 1) >> scale));
// for (int x = 0; x < width; x++) {
// int wL = 32 >> MIN(31, ((x << 1) >> scale));
// int wTL = (wL >> 4) + (wT >> 4);
// dst[x + y * width] = CLIP_TO_PIXEL((wL * used_ref->left[y + 1]
// + wT * used_ref->top[x + 1]
// - wTL * used_ref->top[0]
// + (64 - wL - wT + wTL) * dst[x + y * width] + 32) >> 6);
// }
// }
//}
//else if (mode == 18) { // horizontal
// for (int y = 0; y < width; y++) {
// int wT = 32 >> MIN(31, ((y << 1) >> scale));
// for (int x = 0; x < width; x++) {
// int wTL = wT;
// dst[x + y * width] = CLIP_TO_PIXEL((wT * used_ref->top[x + 1]
// - wTL * used_ref->top[0]
// + (64 - wT + wTL) * dst[x + y * width] + 32) >> 6);
// }
// }
//}
//else if (mode == 50) { // vertical
// for (int y = 0; y < width; y++) {
// for (int x = 0; x < width; x++) {
// int wL = 32 >> MIN(31, ((x << 1) >> scale));
// int wTL = wL;
// dst[x + y * width] = CLIP_TO_PIXEL((wL * used_ref->left[y + 1]
// - wTL * used_ref->top[0]
// + (64 - wL + wTL) * dst[x + y * width] + 32) >> 6);
// }
// }
//}
}
}
}
@ -628,7 +593,7 @@ static void intra_recon_tb_leaf(
kvz_pixel pred[32 * 32];
const bool filter_boundary = color == COLOR_Y && !(cfg->lossless && cfg->implicit_rdpcm);
kvz_intra_predict(&refs, log2width, intra_mode, color, pred, filter_boundary);
kvz_intra_predict(state, &refs, log2width, intra_mode, color, pred, filter_boundary);
const int index = lcu_px.x + lcu_px.y * lcu_width;
kvz_pixel *block = NULL;

View file

@ -1,5 +1,4 @@
#ifndef INTRA_H_
#define INTRA_H_
#pragma once
/*****************************************************************************
* This file is part of Kvazaar HEVC encoder.
*
@ -62,26 +61,6 @@ int8_t kvz_intra_get_dir_luma_predictor(
const cu_info_t *const left_pu,
const cu_info_t *const above_pu);
#if KVZ_SEL_ENCRYPTION
/**
* \brief Function for deriving intra luma predictions with encryption
* \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
*/
int8_t kvz_intra_get_dir_luma_predictor_encry(
const uint32_t x,
const uint32_t y,
int8_t *preds,
const cu_info_t *const cur_pu,
const cu_info_t *const left_pu,
const cu_info_t *const above_pu);
#endif
/**
* \brief Generage angular predictions.
* \param width Width in pixels, range 4..32.
@ -110,6 +89,7 @@ void kvz_intra_build_reference(
* \param filter_boundary Whether to filter the boundary on modes 10 and 26.
*/
void kvz_intra_predict(
encoder_state_t *const state,
kvz_intra_references *refs,
int_fast8_t log2_width,
int_fast8_t mode,
@ -127,4 +107,3 @@ void kvz_intra_recon_cu(
cu_info_t *cur_cu,
lcu_t *lcu);
#endif

View file

@ -390,6 +390,9 @@ typedef struct kvz_config
/** \brief Enable Early Skip Mode Decision */
uint8_t early_skip;
/** \brief Disable intra smoothing when true */
uint8_t intra_smoothing_disabled;
} kvz_config;
/**

View file

@ -524,11 +524,11 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth,
const int last_mode = (ctrl->cfg.amp_enable && cu_width >= 16) ? 5 : 1;
for (int i = first_mode; i <= last_mode; ++i) {
kvz_search_cu_smp(state,
x, y,
depth,
mp_modes[i],
&work_tree[depth + 1],
&mode_cost, &mode_bitcost);
x, y,
depth,
mp_modes[i],
&work_tree[depth + 1],
&mode_cost, &mode_bitcost);
if (mode_cost < cost) {
cost = mode_cost;
inter_bitcost = mode_bitcost;

View file

@ -341,7 +341,7 @@ static void search_intra_chroma_rough(encoder_state_t * const state,
kvz_pixels_blit(orig_u, orig_block, width, width, origstride, width);
for (int i = 0; i < 5; ++i) {
if (modes[i] == luma_mode) continue;
kvz_intra_predict(refs_u, log2_width_c, modes[i], COLOR_U, pred, false);
kvz_intra_predict(state, refs_u, log2_width_c, modes[i], COLOR_U, pred, false);
//costs[i] += get_cost(encoder_state, pred, orig_block, satd_func, sad_func, width);
costs[i] += satd_func(pred, orig_block);
}
@ -349,7 +349,7 @@ static void search_intra_chroma_rough(encoder_state_t * const state,
kvz_pixels_blit(orig_v, orig_block, width, width, origstride, width);
for (int i = 0; i < 5; ++i) {
if (modes[i] == luma_mode) continue;
kvz_intra_predict(refs_v, log2_width_c, modes[i], COLOR_V, pred, false);
kvz_intra_predict(state, refs_v, log2_width_c, modes[i], COLOR_V, pred, false);
//costs[i] += get_cost(encoder_state, pred, orig_block, satd_func, sad_func, width);
costs[i] += satd_func(pred, orig_block);
}
@ -436,7 +436,7 @@ static int8_t search_intra_rough(encoder_state_t * const state,
double costs_out[PARALLEL_BLKS] = { 0 };
for (int i = 0; i < PARALLEL_BLKS; ++i) {
if (mode + i * offset <= 66) {
kvz_intra_predict(refs, log2_width, mode + i * offset, COLOR_Y, preds[i], filter_boundary);
kvz_intra_predict(state, refs, log2_width, mode + i * offset, COLOR_Y, preds[i], filter_boundary);
}
}
@ -475,7 +475,7 @@ static int8_t search_intra_rough(encoder_state_t * const state,
if (mode_in_range) {
for (int i = 0; i < PARALLEL_BLKS; ++i) {
if (test_modes[i] >= 2 && test_modes[i] <= 66) {
kvz_intra_predict(refs, log2_width, test_modes[i], COLOR_Y, preds[i], filter_boundary);
kvz_intra_predict(state, refs, log2_width, test_modes[i], COLOR_Y, preds[i], filter_boundary);
}
}
@ -512,7 +512,7 @@ static int8_t search_intra_rough(encoder_state_t * const state,
}
if (!has_mode) {
kvz_intra_predict(refs, log2_width, mode, COLOR_Y, preds[0], filter_boundary);
kvz_intra_predict(state, refs, log2_width, mode, COLOR_Y, preds[0], filter_boundary);
costs[modes_selected] = get_cost(state, preds[0], orig_block, satd_func, sad_func, width);
modes[modes_selected] = mode;
++modes_selected;