Permit negative QP deltas in ROI

Delta QPs should not be arbitrarily restricted to positive values.
This commit is contained in:
Arttu Ylä-Outinen 2017-04-24 14:10:49 +03:00
parent edfbd6f122
commit 79cb3a2fd3
3 changed files with 4 additions and 4 deletions

View file

@ -1021,7 +1021,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value)
}
const unsigned size = width * height;
uint8_t *dqp_array = calloc((size_t)size, sizeof(cfg->roi.dqps[0]));
int8_t *dqp_array = calloc((size_t)size, sizeof(cfg->roi.dqps[0]));
if (!dqp_array) {
fprintf(stderr, "Failed to allocate memory for ROI table.\n");
fclose(f);
@ -1040,7 +1040,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value)
fclose(f);
return 0;
}
dqp_array[i] = (uint8_t)number;
dqp_array[i] = CLIP(-51, 51, number);
}
fclose(f);

View file

@ -335,7 +335,7 @@ typedef struct kvz_config
struct {
int32_t width;
int32_t height;
uint8_t *dqps;
int8_t *dqps;
} roi; /*!< \since 3.14.0 \brief Map of delta QPs for region of interest coding. */
unsigned slices; /*!< \since 3.15.0 \brief How to map slices to frame. */

View file

@ -291,7 +291,7 @@ void kvz_set_lcu_lambda_and_qp(encoder_state_t * const state,
};
int roi_index = roi.x + roi.y * ctrl->cfg.roi.width;
int dqp = ctrl->cfg.roi.dqps[roi_index];
state->qp = state->frame->QP + dqp;
state->qp = CLIP(0, 51, state->frame->QP + dqp);
state->lambda = qp_to_lamba(state, state->qp);
state->lambda_sqrt = sqrt(state->frame->lambda);