mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
Added cfg variable intra_smoothing_disabled and some cleanup
This commit is contained in:
parent
eb2caf9118
commit
94d89f03c7
|
@ -141,6 +141,8 @@ int kvz_config_init(kvz_config *cfg)
|
||||||
cfg->max_merge = 5;
|
cfg->max_merge = 5;
|
||||||
cfg->early_skip = true;
|
cfg->early_skip = true;
|
||||||
|
|
||||||
|
cfg->intra_smoothing_disabled = false;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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, 1, 1, "implicit_rdpcm_enabled_flag");
|
||||||
WRITE_U(stream, 0, 1, "explicit_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, "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, "high_precision_offsets_enabled_flag");
|
||||||
WRITE_U(stream, 0, 1, "persistent_rice_adaptation_enabled_flag");
|
WRITE_U(stream, 0, 1, "persistent_rice_adaptation_enabled_flag");
|
||||||
WRITE_U(stream, 0, 1, "cabac_bypass_alignment_enabled_flag");
|
WRITE_U(stream, 0, 1, "cabac_bypass_alignment_enabled_flag");
|
||||||
|
|
47
src/intra.c
47
src/intra.c
|
@ -119,8 +119,6 @@ int8_t kvz_intra_get_dir_luma_predictor(
|
||||||
preds[5] = (left_intra_dir % mod) + 2;
|
preds[5] = (left_intra_dir % mod) + 2;
|
||||||
}
|
}
|
||||||
} else { // If we have two distinct predictions
|
} else { // If we have two distinct predictions
|
||||||
//preds[0] = left_intra_dir;
|
|
||||||
//preds[1] = above_intra_dir;
|
|
||||||
number_of_candidates = 2;
|
number_of_candidates = 2;
|
||||||
uint8_t max_cand_mode_idx = preds[0] > preds[1] ? 0 : 1;
|
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(
|
void kvz_intra_predict(
|
||||||
|
encoder_state_t *const state,
|
||||||
kvz_intra_references *refs,
|
kvz_intra_references *refs,
|
||||||
int_fast8_t log2_width,
|
int_fast8_t log2_width,
|
||||||
int_fast8_t mode,
|
int_fast8_t mode,
|
||||||
|
@ -246,9 +245,10 @@ void kvz_intra_predict(
|
||||||
bool filter_boundary)
|
bool filter_boundary)
|
||||||
{
|
{
|
||||||
const int_fast8_t width = 1 << log2_width;
|
const int_fast8_t width = 1 << log2_width;
|
||||||
|
const kvz_config *cfg = &state->encoder_control->cfg;
|
||||||
|
|
||||||
const kvz_intra_ref *used_ref = &refs->ref;
|
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.
|
// For chroma, DC and 4x4 blocks, always use unfiltered reference.
|
||||||
} else if (mode == 0) {
|
} else if (mode == 0) {
|
||||||
// Otherwise, use filtered for planar.
|
// Otherwise, use filtered for planar.
|
||||||
|
@ -284,8 +284,8 @@ void kvz_intra_predict(
|
||||||
}
|
}
|
||||||
|
|
||||||
// pdpc
|
// pdpc
|
||||||
bool pdpcCondition = (mode == 0 || mode == 1 || mode == 18 || mode == 50);
|
//bool pdpcCondition = (mode == 0 || mode == 1 || mode == 18 || mode == 50);
|
||||||
if (pdpcCondition)
|
//if (pdpcCondition)
|
||||||
{
|
{
|
||||||
// TODO: replace latter log2_width with log2_height
|
// TODO: replace latter log2_width with log2_height
|
||||||
const int scale = ((log2_width - 2 + log2_width - 2 + 2) >> 2);
|
const int scale = ((log2_width - 2 + log2_width - 2 + 2) >> 2);
|
||||||
|
@ -301,41 +301,6 @@ void kvz_intra_predict(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//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];
|
kvz_pixel pred[32 * 32];
|
||||||
const bool filter_boundary = color == COLOR_Y && !(cfg->lossless && cfg->implicit_rdpcm);
|
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;
|
const int index = lcu_px.x + lcu_px.y * lcu_width;
|
||||||
kvz_pixel *block = NULL;
|
kvz_pixel *block = NULL;
|
||||||
|
|
25
src/intra.h
25
src/intra.h
|
@ -1,5 +1,4 @@
|
||||||
#ifndef INTRA_H_
|
#pragma once
|
||||||
#define INTRA_H_
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* This file is part of Kvazaar HEVC encoder.
|
* 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 left_pu,
|
||||||
const cu_info_t *const above_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.
|
* \brief Generage angular predictions.
|
||||||
* \param width Width in pixels, range 4..32.
|
* \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.
|
* \param filter_boundary Whether to filter the boundary on modes 10 and 26.
|
||||||
*/
|
*/
|
||||||
void kvz_intra_predict(
|
void kvz_intra_predict(
|
||||||
|
encoder_state_t *const state,
|
||||||
kvz_intra_references *refs,
|
kvz_intra_references *refs,
|
||||||
int_fast8_t log2_width,
|
int_fast8_t log2_width,
|
||||||
int_fast8_t mode,
|
int_fast8_t mode,
|
||||||
|
@ -127,4 +107,3 @@ void kvz_intra_recon_cu(
|
||||||
cu_info_t *cur_cu,
|
cu_info_t *cur_cu,
|
||||||
lcu_t *lcu);
|
lcu_t *lcu);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -390,6 +390,9 @@ typedef struct kvz_config
|
||||||
/** \brief Enable Early Skip Mode Decision */
|
/** \brief Enable Early Skip Mode Decision */
|
||||||
uint8_t early_skip;
|
uint8_t early_skip;
|
||||||
|
|
||||||
|
/** \brief Disable intra smoothing when true */
|
||||||
|
uint8_t intra_smoothing_disabled;
|
||||||
|
|
||||||
} kvz_config;
|
} kvz_config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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);
|
kvz_pixels_blit(orig_u, orig_block, width, width, origstride, width);
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i < 5; ++i) {
|
||||||
if (modes[i] == luma_mode) continue;
|
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] += get_cost(encoder_state, pred, orig_block, satd_func, sad_func, width);
|
||||||
costs[i] += satd_func(pred, orig_block);
|
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);
|
kvz_pixels_blit(orig_v, orig_block, width, width, origstride, width);
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i < 5; ++i) {
|
||||||
if (modes[i] == luma_mode) continue;
|
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] += get_cost(encoder_state, pred, orig_block, satd_func, sad_func, width);
|
||||||
costs[i] += satd_func(pred, orig_block);
|
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 };
|
double costs_out[PARALLEL_BLKS] = { 0 };
|
||||||
for (int i = 0; i < PARALLEL_BLKS; ++i) {
|
for (int i = 0; i < PARALLEL_BLKS; ++i) {
|
||||||
if (mode + i * offset <= 66) {
|
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) {
|
if (mode_in_range) {
|
||||||
for (int i = 0; i < PARALLEL_BLKS; ++i) {
|
for (int i = 0; i < PARALLEL_BLKS; ++i) {
|
||||||
if (test_modes[i] >= 2 && test_modes[i] <= 66) {
|
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) {
|
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);
|
costs[modes_selected] = get_cost(state, preds[0], orig_block, satd_func, sad_func, width);
|
||||||
modes[modes_selected] = mode;
|
modes[modes_selected] = mode;
|
||||||
++modes_selected;
|
++modes_selected;
|
||||||
|
|
Loading…
Reference in a new issue