mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-24 02:24:07 +00:00
[alf] remove alf clipping functions and free tqj_alf_process also when new job is allocated
This commit is contained in:
parent
eb491ecea2
commit
226d7a9f53
29
src/alf.c
29
src/alf.c
|
@ -13,6 +13,8 @@
|
|||
#include "kvz_math.h"
|
||||
#include "reshape.h"
|
||||
|
||||
extern kvz_pixel kvz_fast_clip_32bit_to_pixel(int32_t value);
|
||||
|
||||
#if MAX_NUM_CC_ALF_FILTERS>1
|
||||
typedef struct filter_idx_count
|
||||
{
|
||||
|
@ -99,24 +101,9 @@ static void init_ctu_alternative_chroma(const alf_aps *alf_param, uint8_t* ctu_a
|
|||
}
|
||||
}
|
||||
|
||||
static int16_t alf_clip3(const int16_t minVal, const int16_t maxVal, const int16_t a)
|
||||
{
|
||||
return MIN(MAX(minVal, a), maxVal);
|
||||
}
|
||||
|
||||
static int16_t clip_alf(const int16_t clip, const int16_t ref, const int16_t val0, const int16_t val1)
|
||||
{
|
||||
return alf_clip3(-clip, +clip, val0 - ref) + alf_clip3(-clip, +clip, val1 - ref);
|
||||
}
|
||||
|
||||
static int alf_clip_pixel(const int a, const clp_rng clp_rng)
|
||||
{
|
||||
return MIN(MAX(clp_rng.min, a), clp_rng.max);
|
||||
}
|
||||
|
||||
static int alf_clip3_int(const int minVal, const int maxVal, const int a)
|
||||
{
|
||||
return MIN(MAX(minVal, a), maxVal);
|
||||
return CLIP(-clip, +clip, val0 - ref) + CLIP(-clip, +clip, val1 - ref);
|
||||
}
|
||||
|
||||
static void get_clip_max(const alf_covariance *cov, int *clip_max)
|
||||
|
@ -1778,9 +1765,9 @@ static void filter_blk_cc_alf(encoder_state_t * const state,
|
|||
|
||||
sum = (sum + ((1 << 7/*m_scaleBits*/) >> 1)) >> 7/*m_scaleBits*/;
|
||||
const int offset = 1 << clp_rngs.comp[comp_id].bd >> 1;
|
||||
sum = alf_clip_pixel(sum + offset, clp_rngs.comp[comp_id]) - offset;
|
||||
sum = kvz_fast_clip_32bit_to_pixel(sum + offset) - offset;
|
||||
sum += src_self[jj];
|
||||
src_self[jj] = alf_clip_pixel(sum, clp_rngs.comp[comp_id]);
|
||||
src_self[jj] = kvz_fast_clip_32bit_to_pixel(sum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5702,7 +5689,7 @@ static void alf_filter_block(encoder_state_t * const state,
|
|||
}
|
||||
sum += curr;
|
||||
|
||||
p_rec_1[jj] = alf_clip_pixel(sum, clp_rng);
|
||||
p_rec_1[jj] = kvz_fast_clip_32bit_to_pixel(sum);
|
||||
|
||||
p_img_0++;
|
||||
p_img_1++;
|
||||
|
@ -5985,11 +5972,11 @@ static void alf_derive_classification_blk(encoder_state_t * const state,
|
|||
const int y = (i + blk_dst_y) & (vb_ctu_height - 1);
|
||||
if (y == vb_pos - 4 || y == vb_pos)
|
||||
{
|
||||
activity = alf_clip3_int(0, max_activity, (temp_act * 96) >> shift);
|
||||
activity = CLIP(0, max_activity, (temp_act * 96) >> shift);
|
||||
}
|
||||
else
|
||||
{
|
||||
activity = alf_clip3_int(0, max_activity, (temp_act * 64) >> shift);
|
||||
activity = CLIP(0, max_activity, (temp_act * 64) >> shift);
|
||||
}
|
||||
|
||||
int class_idx = th[activity];
|
||||
|
|
|
@ -672,8 +672,6 @@ static void encoder_state_worker_encode_lcu_search(void * opaque)
|
|||
kvz_sao_search_lcu(state, lcu->position.x, lcu->position.y);
|
||||
encoder_sao_reconstruct(state, lcu);
|
||||
}
|
||||
|
||||
//fprintf(stderr, "Recon done: %d\r\n", lcu->id);
|
||||
}
|
||||
|
||||
static void encoder_state_worker_encode_lcu_bitstream(void * opaque)
|
||||
|
@ -1621,6 +1619,7 @@ void kvz_encode_one_frame(encoder_state_t * const state, kvz_picture* frame)
|
|||
|
||||
// Create a separate job for ALF done after everything else, and only then do final bitstream writing (for ALF parameters)
|
||||
if (state->encoder_control->cfg.alf_type && state->encoder_control->cfg.wpp) {
|
||||
kvz_threadqueue_free_job(&state->tqj_alf_process);
|
||||
encoder_state_t* child_state = state;
|
||||
while (child_state->lcu_order == NULL) child_state = &child_state->children[0];
|
||||
state->tqj_alf_process = kvz_threadqueue_job_create(kvz_alf_enc_process_job, child_state);
|
||||
|
|
Loading…
Reference in a new issue