mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-23 18:14:06 +00:00
Define qp_delta_min & max in global.h instead of calculating them locally.
This commit is contained in:
parent
d5fe6c3737
commit
bc1206a4d3
|
@ -25,6 +25,7 @@
|
|||
#include "cu.h"
|
||||
#include "encoder.h"
|
||||
#include "extras/crypto.h"
|
||||
#include "global.h"
|
||||
#include "imagelist.h"
|
||||
#include "inter.h"
|
||||
#include "intra.h"
|
||||
|
@ -270,10 +271,7 @@ static void encode_transform_coeff(encoder_state_t * const state,
|
|||
const int qp_pred = kvz_get_cu_ref_qp(state, x_cu, y_cu, state->last_qp);
|
||||
const int qp_delta = cur_cu->qp - qp_pred;
|
||||
// Possible deltaQP range depends on bit depth as stated in HEVC specification.
|
||||
int qp_bd_offset = 3 * (KVZ_BIT_DEPTH - 8);
|
||||
int qp_delta_min = -(26 + qp_bd_offset);
|
||||
int qp_delta_max = 25 + qp_bd_offset;
|
||||
assert(qp_delta >= qp_delta_min && qp_delta <= qp_delta_max && "QP delta not in valid range.");
|
||||
assert(qp_delta >= KVZ_QP_DELTA_MIN && qp_delta <= KVZ_QP_DELTA_MAX && "QP delta not in valid range.");
|
||||
|
||||
const int qp_delta_abs = ABS(qp_delta);
|
||||
cabac_data_t* cabac = &state->cabac;
|
||||
|
|
|
@ -349,4 +349,8 @@ typedef enum { COLOR_Y = 0, COLOR_U, COLOR_V } color_t;
|
|||
# define COMPILE_ARM 0
|
||||
#endif
|
||||
|
||||
// Min & max delta QP limits based on bit depth
|
||||
#define KVZ_QP_DELTA_MIN -(26 + 3 * (KVZ_BIT_DEPTH - 8))
|
||||
#define KVZ_QP_DELTA_MAX 25 + 3 * (KVZ_BIT_DEPTH - 8)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -803,9 +803,7 @@ static double qp_to_lambda(encoder_state_t* const state, int qp)
|
|||
// Maximum delta QP is clipped according to ITU T-REC-H.265 specification chapter 7.4.9.10 Transform unit semantics
|
||||
// Clipping range is a function of bit depth
|
||||
// Since this value will be later combined with qp_pred, clip to half of that instead to be safe
|
||||
int qp_delta_min = (26 + (3 * (KVZ_BIT_DEPTH - 8))) / 2;
|
||||
int qp_delta_max = (25 + (3 * (KVZ_BIT_DEPTH - 8))) / 2;
|
||||
state->qp = CLIP(state->frame->QP - qp_delta_min, state->frame->QP + qp_delta_max, state->qp);
|
||||
state->qp = CLIP(state->frame->QP + KVZ_QP_DELTA_MIN / 2, state->frame->QP + KVZ_QP_DELTA_MAX / 2, state->qp);
|
||||
state->qp = CLIP_TO_QP(state->qp);
|
||||
state->lambda = qp_to_lambda(state, state->qp);
|
||||
state->lambda_sqrt = sqrt(state->lambda);
|
||||
|
@ -1149,9 +1147,7 @@ void kvz_set_lcu_lambda_and_qp(encoder_state_t * const state,
|
|||
// Maximum delta QP is clipped according to ITU T-REC-H.265 specification chapter 7.4.9.10 Transform unit semantics
|
||||
// Clipping range is a function of bit depth
|
||||
// Since this value will be later combined with qp_pred, clip to half of that instead to be safe
|
||||
int qp_delta_min = (26 + (3 * (KVZ_BIT_DEPTH - 8))) / 2;
|
||||
int qp_delta_max = (25 + (3 * (KVZ_BIT_DEPTH - 8))) / 2;
|
||||
state->qp = CLIP(state->frame->QP - qp_delta_min, state->frame->QP + qp_delta_max, state->qp);
|
||||
state->qp = CLIP(state->frame->QP + KVZ_QP_DELTA_MIN / 2, state->frame->QP + KVZ_QP_DELTA_MAX / 2, state->qp);
|
||||
state->qp = CLIP_TO_QP(state->qp);
|
||||
state->lambda = qp_to_lambda(state, state->qp);
|
||||
state->lambda_sqrt = sqrt(state->lambda);
|
||||
|
|
Loading…
Reference in a new issue