Signed-off-by: Mark Thompson <s...@jkqxz.net> --- This can be set by the user to ensure that the first frame of a stream is encoded at with a good QP (often it starts too high and takes a few frames to get down to the right range). The current code continues to be used if the value is not set (is zero).
src/gen6_mfc_common.c | 24 +++++++++++++++--------- src/i965_encoder.c | 2 ++ src/i965_encoder.h | 1 + 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/gen6_mfc_common.c b/src/gen6_mfc_common.c index e8596ff..8907751 100644 --- a/src/gen6_mfc_common.c +++ b/src/gen6_mfc_common.c @@ -168,16 +168,22 @@ static void intel_mfc_brc_init(struct encode_state *encode_state, bpf = mfc_context->brc.bits_per_frame[i] = bitrate/framerate; - if ((bpf > qp51_size) && (bpf < qp1_size)) { - mfc_context->brc.qp_prime_y[i][SLICE_TYPE_P] = 51 - 50*(bpf - qp51_size)/(qp1_size - qp51_size); - } - else if (bpf >= qp1_size) - mfc_context->brc.qp_prime_y[i][SLICE_TYPE_P] = 1; - else if (bpf <= qp51_size) - mfc_context->brc.qp_prime_y[i][SLICE_TYPE_P] = 51; + if (encoder_context->brc.initial_qp) { + mfc_context->brc.qp_prime_y[i][SLICE_TYPE_I] = encoder_context->brc.initial_qp; + mfc_context->brc.qp_prime_y[i][SLICE_TYPE_P] = encoder_context->brc.initial_qp; + mfc_context->brc.qp_prime_y[i][SLICE_TYPE_B] = encoder_context->brc.initial_qp; + } else { + if ((bpf > qp51_size) && (bpf < qp1_size)) { + mfc_context->brc.qp_prime_y[i][SLICE_TYPE_P] = 51 - 50*(bpf - qp51_size)/(qp1_size - qp51_size); + } + else if (bpf >= qp1_size) + mfc_context->brc.qp_prime_y[i][SLICE_TYPE_P] = 1; + else if (bpf <= qp51_size) + mfc_context->brc.qp_prime_y[i][SLICE_TYPE_P] = 51; - mfc_context->brc.qp_prime_y[i][SLICE_TYPE_I] = mfc_context->brc.qp_prime_y[i][SLICE_TYPE_P]; - mfc_context->brc.qp_prime_y[i][SLICE_TYPE_B] = mfc_context->brc.qp_prime_y[i][SLICE_TYPE_I]; + mfc_context->brc.qp_prime_y[i][SLICE_TYPE_I] = mfc_context->brc.qp_prime_y[i][SLICE_TYPE_P]; + mfc_context->brc.qp_prime_y[i][SLICE_TYPE_B] = mfc_context->brc.qp_prime_y[i][SLICE_TYPE_I]; + } BRC_CLIP(mfc_context->brc.qp_prime_y[i][SLICE_TYPE_I], (int)encoder_context->brc.min_qp, 51); BRC_CLIP(mfc_context->brc.qp_prime_y[i][SLICE_TYPE_P], (int)encoder_context->brc.min_qp, 51); diff --git a/src/i965_encoder.c b/src/i965_encoder.c index 3056900..0a648d4 100644 --- a/src/i965_encoder.c +++ b/src/i965_encoder.c @@ -576,8 +576,10 @@ intel_encoder_check_rate_control_parameter(VADriverContextP ctx, } if (encoder_context->brc.window_size != misc->window_size || + encoder_context->brc.initial_qp != misc->initial_qp || encoder_context->brc.min_qp != misc->min_qp) { encoder_context->brc.window_size = misc->window_size; + encoder_context->brc.initial_qp = misc->initial_qp; encoder_context->brc.min_qp = misc->min_qp; encoder_context->brc.need_reset = 1; } diff --git a/src/i965_encoder.h b/src/i965_encoder.h index 16a6f3f..829df9d 100644 --- a/src/i965_encoder.h +++ b/src/i965_encoder.h @@ -92,6 +92,7 @@ struct intel_encoder_context unsigned int hrd_buffer_size; unsigned int hrd_initial_buffer_fullness; unsigned int window_size; + unsigned int initial_qp; unsigned int min_qp; unsigned int need_reset; -- 2.11.0 _______________________________________________ Libva mailing list Libva@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libva