mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-30 12:44:07 +00:00
Revert to 6924d90052
due to broken visual studio build
This commit is contained in:
parent
2852baa673
commit
1dd0619bd7
|
@ -128,7 +128,6 @@ libkvazaar_la_SOURCES = \
|
|||
strategies/generic/encode_coding_tree-generic.h \
|
||||
strategies/missing-intel-intrinsics.h \
|
||||
strategies/optimized_sad_func_ptr_t.h \
|
||||
strategies/sao_shared_generics.h \
|
||||
strategies/strategies-common.h \
|
||||
strategies/strategies-dct.c \
|
||||
strategies/strategies-dct.h \
|
||||
|
|
32
src/sao.c
32
src/sao.c
|
@ -157,36 +157,29 @@ static float sao_mode_bits_band(const encoder_state_t * const state,
|
|||
return mode_bits;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief calculate an array of intensity correlations for each intensity value
|
||||
*/
|
||||
// NOTE: There's also an AVX2 variant of this in strategies/avx2/sao-avx2.c.
|
||||
// It has to be separate, because it returns the offset array in different
|
||||
// format (an array of YMM vectors).
|
||||
void kvz_calc_sao_offset_array(const encoder_control_t * const encoder, const sao_info_t *sao, int *offset, color_t color_i)
|
||||
{
|
||||
int32_t val;
|
||||
const int32_t values = (1<<encoder->bitdepth);
|
||||
const int32_t shift = encoder->bitdepth-5;
|
||||
const int32_t band_pos = (color_i == COLOR_V) ? 1 : 0;
|
||||
const int32_t cur_bp = sao->band_position[band_pos];
|
||||
int val;
|
||||
int values = (1<<encoder->bitdepth);
|
||||
int shift = encoder->bitdepth-5;
|
||||
int band_pos = (color_i == COLOR_V) ? 1 : 0;
|
||||
|
||||
// Loop through all intensity values and construct an offset array
|
||||
for (val = 0; val < values; val++) {
|
||||
int32_t cur_band = val >> shift;
|
||||
int32_t cb_minus_cbp = cur_band - cur_bp;
|
||||
|
||||
if (cb_minus_cbp >= 0 && cb_minus_cbp <= 3) {
|
||||
uint32_t offset_id = cb_minus_cbp + 1 + 5 * band_pos;
|
||||
int32_t val_unclipped = val + sao->offsets[offset_id];
|
||||
offset[val] = CLIP(0, values - 1, val_unclipped);
|
||||
|
||||
int cur_band = val>>shift;
|
||||
if (cur_band >= sao->band_position[band_pos] && cur_band < sao->band_position[band_pos] + 4) {
|
||||
offset[val] = CLIP(0, values - 1, val + sao->offsets[cur_band - sao->band_position[band_pos] + 1 + 5 * band_pos]);
|
||||
} else {
|
||||
offset[val] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \param orig_data Original pixel data. 64x64 for luma, 32x32 for chroma.
|
||||
* \param rec_data Reconstructed pixel data. 64x64 for luma, 32x32 for chroma.
|
||||
|
@ -261,11 +254,8 @@ static void calc_sao_bands(const encoder_state_t * const state, const kvz_pixel
|
|||
//Loop pixels and take top 5 bits to classify different bands
|
||||
for (y = 0; y < block_height; ++y) {
|
||||
for (x = 0; x < block_width; ++x) {
|
||||
int32_t curr_pos = y * block_width + x;
|
||||
|
||||
kvz_pixel sb_index = rec_data[curr_pos] >> shift;
|
||||
sao_bands[0][sb_index] += orig_data[curr_pos] - rec_data[curr_pos];
|
||||
sao_bands[1][sb_index]++;
|
||||
sao_bands[0][rec_data[y * block_width + x]>>shift] += orig_data[y * block_width + x] - rec_data[y * block_width + x];
|
||||
sao_bands[1][rec_data[y * block_width + x]>>shift]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -19,7 +19,6 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "strategies/generic/sao-generic.h"
|
||||
#include "strategies/generic/sao_shared_generics.h"
|
||||
|
||||
#include "cu.h"
|
||||
#include "encoder.h"
|
||||
|
@ -29,6 +28,51 @@
|
|||
#include "strategyselector.h"
|
||||
|
||||
|
||||
// Mapping of edge_idx values to eo-classes.
|
||||
static int sao_calc_eo_cat(kvz_pixel a, kvz_pixel b, kvz_pixel c)
|
||||
{
|
||||
// Mapping relationships between a, b and c to eo_idx.
|
||||
static const int sao_eo_idx_to_eo_category[] = { 1, 2, 0, 3, 4 };
|
||||
|
||||
int eo_idx = 2 + SIGN3((int)c - (int)a) + SIGN3((int)c - (int)b);
|
||||
|
||||
return sao_eo_idx_to_eo_category[eo_idx];
|
||||
}
|
||||
|
||||
|
||||
static int sao_edge_ddistortion_generic(const kvz_pixel *orig_data,
|
||||
const kvz_pixel *rec_data,
|
||||
int block_width,
|
||||
int block_height,
|
||||
int eo_class,
|
||||
int offsets[NUM_SAO_EDGE_CATEGORIES])
|
||||
{
|
||||
int y, x;
|
||||
int sum = 0;
|
||||
vector2d_t a_ofs = g_sao_edge_offsets[eo_class][0];
|
||||
vector2d_t b_ofs = g_sao_edge_offsets[eo_class][1];
|
||||
|
||||
for (y = 1; y < block_height - 1; ++y) {
|
||||
for (x = 1; x < block_width - 1; ++x) {
|
||||
const kvz_pixel *c_data = &rec_data[y * block_width + x];
|
||||
kvz_pixel a = c_data[a_ofs.y * block_width + a_ofs.x];
|
||||
kvz_pixel c = c_data[0];
|
||||
kvz_pixel b = c_data[b_ofs.y * block_width + b_ofs.x];
|
||||
|
||||
int offset = offsets[sao_calc_eo_cat(a, b, c)];
|
||||
|
||||
if (offset != 0) {
|
||||
int diff = orig_data[y * block_width + x] - c;
|
||||
// Offset is applied to reconstruction, so it is subtracted from diff.
|
||||
sum += (diff - offset) * (diff - offset) - diff * diff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \param orig_data Original pixel data. 64x64 for luma, 32x32 for chroma.
|
||||
* \param rec_data Reconstructed pixel data. 64x64 for luma, 32x32 for chroma.
|
||||
|
@ -49,9 +93,6 @@ static void calc_sao_edge_dir_generic(const kvz_pixel *orig_data,
|
|||
|
||||
// Don't sample the edge pixels because this function doesn't have access to
|
||||
// their neighbours.
|
||||
|
||||
|
||||
|
||||
for (y = 1; y < block_height - 1; ++y) {
|
||||
for (x = 1; x < block_width - 1; ++x) {
|
||||
const kvz_pixel *c_data = &rec_data[y * block_width + x];
|
||||
|
@ -111,6 +152,36 @@ static void sao_reconstruct_color_generic(const encoder_control_t * const encode
|
|||
}
|
||||
|
||||
|
||||
static int sao_band_ddistortion_generic(const encoder_state_t * const state,
|
||||
const kvz_pixel *orig_data,
|
||||
const kvz_pixel *rec_data,
|
||||
int block_width,
|
||||
int block_height,
|
||||
int band_pos,
|
||||
int sao_bands[4])
|
||||
{
|
||||
int y, x;
|
||||
int shift = state->encoder_control->bitdepth-5;
|
||||
int sum = 0;
|
||||
|
||||
for (y = 0; y < block_height; ++y) {
|
||||
for (x = 0; x < block_width; ++x) {
|
||||
int band = (rec_data[y * block_width + x] >> shift) - band_pos;
|
||||
int offset = 0;
|
||||
if (band >= 0 && band < 4) {
|
||||
offset = sao_bands[band];
|
||||
}
|
||||
if (offset != 0) {
|
||||
int diff = orig_data[y * block_width + x] - rec_data[y * block_width + x];
|
||||
// Offset is applied to reconstruction, so it is subtracted from diff.
|
||||
sum += (diff - offset) * (diff - offset) - diff * diff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
int kvz_strategy_register_sao_generic(void* opaque, uint8_t bitdepth)
|
||||
{
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
#ifndef SAO_BAND_DDISTORTION_H_
|
||||
#define SAO_BAND_DDISTORTION_H_
|
||||
|
||||
// #include "encoder.h"
|
||||
#include "encoderstate.h"
|
||||
#include "kvazaar.h"
|
||||
#include "sao.h"
|
||||
|
||||
// Mapping of edge_idx values to eo-classes.
|
||||
static int sao_calc_eo_cat(kvz_pixel a, kvz_pixel b, kvz_pixel c)
|
||||
{
|
||||
// Mapping relationships between a, b and c to eo_idx.
|
||||
static const int sao_eo_idx_to_eo_category[] = { 1, 2, 0, 3, 4 };
|
||||
|
||||
int eo_idx = 2 + SIGN3((int)c - (int)a) + SIGN3((int)c - (int)b);
|
||||
|
||||
return sao_eo_idx_to_eo_category[eo_idx];
|
||||
}
|
||||
|
||||
static int sao_edge_ddistortion_generic(const kvz_pixel *orig_data,
|
||||
const kvz_pixel *rec_data,
|
||||
int32_t block_width,
|
||||
int32_t block_height,
|
||||
int32_t eo_class,
|
||||
const int32_t offsets[NUM_SAO_EDGE_CATEGORIES])
|
||||
{
|
||||
int y, x;
|
||||
int32_t sum = 0;
|
||||
vector2d_t a_ofs = g_sao_edge_offsets[eo_class][0];
|
||||
vector2d_t b_ofs = g_sao_edge_offsets[eo_class][1];
|
||||
|
||||
for (y = 1; y < block_height - 1; y++) {
|
||||
for (x = 1; x < block_width - 1; x++) {
|
||||
uint32_t c_pos = y * block_width + x;
|
||||
uint32_t a_pos = (y + a_ofs.y) * block_width + x + a_ofs.x;
|
||||
uint32_t b_pos = (y + b_ofs.y) * block_width + x + b_ofs.x;
|
||||
|
||||
uint8_t a = rec_data[a_pos];
|
||||
uint8_t b = rec_data[b_pos];
|
||||
uint8_t c = rec_data[c_pos];
|
||||
uint8_t orig = orig_data[c_pos];
|
||||
|
||||
int32_t eo_cat = sao_calc_eo_cat(a, b, c);
|
||||
int32_t offset = offsets[eo_cat];
|
||||
|
||||
if (offset != 0) {
|
||||
int32_t diff = orig - c;
|
||||
int32_t delta = diff - offset;
|
||||
int32_t curr = delta * delta - diff * diff;
|
||||
|
||||
sum += curr;
|
||||
}
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
static int sao_band_ddistortion_generic(const encoder_state_t * const state,
|
||||
const kvz_pixel *orig_data,
|
||||
const kvz_pixel *rec_data,
|
||||
int block_width,
|
||||
int block_height,
|
||||
int band_pos,
|
||||
const int sao_bands[4])
|
||||
{
|
||||
int y, x;
|
||||
int shift = state->encoder_control->bitdepth-5;
|
||||
int sum = 0;
|
||||
for (y = 0; y < block_height; ++y) {
|
||||
for (x = 0; x < block_width; ++x) {
|
||||
const int32_t curr_pos = y * block_width + x;
|
||||
|
||||
kvz_pixel rec = rec_data[curr_pos];
|
||||
kvz_pixel orig = orig_data[curr_pos];
|
||||
|
||||
int32_t band = (rec >> shift) - band_pos;
|
||||
int32_t offset = 0;
|
||||
if (band >= 0 && band <= 3) {
|
||||
offset = sao_bands[band];
|
||||
}
|
||||
// Offset is applied to reconstruction, so it is subtracted from diff.
|
||||
|
||||
int32_t diff = orig - rec;
|
||||
int32_t delta = diff - offset;
|
||||
|
||||
int32_t dmask = (offset == 0) ? -1 : 0;
|
||||
diff &= ~dmask;
|
||||
delta &= ~dmask;
|
||||
|
||||
sum += delta * delta - diff * diff;
|
||||
}
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -51,7 +51,7 @@ typedef void (sao_reconstruct_color_func)(const encoder_control_t * const encode
|
|||
|
||||
typedef int (sao_band_ddistortion_func)(const encoder_state_t * const state, const kvz_pixel *orig_data, const kvz_pixel *rec_data,
|
||||
int block_width, int block_height,
|
||||
int band_pos, const int sao_bands[4]);
|
||||
int band_pos, int sao_bands[4]);
|
||||
|
||||
// Declare function pointers.
|
||||
extern sao_edge_ddistortion_func * kvz_sao_edge_ddistortion;
|
||||
|
|
Loading…
Reference in a new issue