[Libva] [PATCH v2] H.264 encoder: respect initial QP setting
Mark Thompson
sw at jkqxz.net
Wed Jan 4 09:15:06 UTC 2017
Signed-off-by: Mark Thompson <sw at jkqxz.net>
---
On 04/01/17 08:50, Xiang, Haihao wrote:
> Could you send your new revision in a separate email with a version number in the future? I thought this email was just a reply
> to the previous email.
Ok, will do.
> BTW I failed to apply the 2nd patch in the patch series by git-am. Could you rebase the 2nd patch?
Sure. Here it is rebased against v2 of the min-qp patch (and otherwise unchanged).
Thanks,
- Mark
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 90cee05..1643efc 100644
--- a/src/gen6_mfc_common.c
+++ b/src/gen6_mfc_common.c
@@ -169,16 +169,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], min_qp, 51);
BRC_CLIP(mfc_context->brc.qp_prime_y[i][SLICE_TYPE_P], 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
More information about the Libva
mailing list