Change clipping of lambda and qp for ctus on OBA rc

instead of clipping qp and lambda to the value of last value from the state
clip to previous frame with same layer and if such frame doesn't exist, clip
to previous frame
This commit is contained in:
Joose Sainio 2020-01-14 14:46:05 +02:00
parent b78aa7b272
commit 1a35c22a52

View file

@ -686,6 +686,7 @@ void kvz_set_ctu_qp_lambda(encoder_state_t * const state, vector2d_t pos) {
const double clip_lambda = state->frame->lambda; const double clip_lambda = state->frame->lambda;
double clip_neighbor_lambda = -1; double clip_neighbor_lambda = -1;
int clip_qp = -1;
if (encoder->cfg.clip_neighbour) { if (encoder->cfg.clip_neighbour) {
for (int temp_index = index - 1; temp_index >= ctu_limit; --temp_index) { for (int temp_index = index - 1; temp_index >= ctu_limit; --temp_index) {
if (state->frame->lcu_stats[temp_index].lambda > 0) { if (state->frame->lcu_stats[temp_index].lambda > 0) {
@ -693,10 +694,27 @@ void kvz_set_ctu_qp_lambda(encoder_state_t * const state, vector2d_t pos) {
break; break;
} }
} }
for (int temp_index = index - 1; temp_index >= ctu_limit; --temp_index) {
if (state->frame->lcu_stats[temp_index].qp > -1) {
clip_qp = state->frame->lcu_stats[temp_index].qp;
break;
}
}
} }
else { else {
encoder_state_t *previous = state->previous_encoder_state;
const int layer = encoder->cfg.gop[state->frame->gop_offset].layer;
int owf = encoder->cfg.owf;
while (layer != encoder->cfg.gop[previous->frame->gop_offset].layer && --owf) {
previous = previous->previous_encoder_state;
}
if (state->frame->lcu_stats[index].lambda > 0) { if (state->frame->lcu_stats[index].lambda > 0) {
clip_neighbor_lambda = state->frame->lcu_stats[index].lambda; clip_neighbor_lambda = previous->frame->lcu_stats[index].lambda;
}
if (state->frame->lcu_stats[index].qp > 0) {
clip_qp = previous->frame->lcu_stats[index].qp;
} }
} }
@ -722,21 +740,6 @@ void kvz_set_ctu_qp_lambda(encoder_state_t * const state, vector2d_t pos) {
est_qp = lambda_to_qp(est_lambda); est_qp = lambda_to_qp(est_lambda);
int clip_qp = -1;
if(encoder->cfg.clip_neighbour) {
for (int temp_index = index - 1; temp_index >= ctu_limit; --temp_index) {
if (state->frame->lcu_stats[temp_index].qp > -1) {
clip_qp = state->frame->lcu_stats[temp_index].qp;
break;
}
}
}
else {
if (state->frame->lcu_stats[index].qp > 0) {
clip_qp = state->frame->lcu_stats[index].qp;
}
}
if( clip_qp > -1) { if( clip_qp > -1) {
est_qp = CLIP(clip_qp - 1 - frame_allocation, est_qp = CLIP(clip_qp - 1 - frame_allocation,
clip_qp + 1 + frame_allocation, clip_qp + 1 + frame_allocation,