[Libva] [PATCH 16/18] encoding: use the qp per every macroblock on Haswell
Zhao, Yakui
yakui.zhao at intel.com
Mon Jan 12 05:01:39 PST 2015
From: Zhao Yakui <yakui.zhao at intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao at intel.com>
---
src/gen75_mfc.c | 14 +++++++++++---
src/gen75_vme.c | 10 +++++++++-
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/src/gen75_mfc.c b/src/gen75_mfc.c
index 4434f5a..f535ddf 100644
--- a/src/gen75_mfc.c
+++ b/src/gen75_mfc.c
@@ -1167,6 +1167,7 @@ gen75_mfc_avc_pipeline_slice_programing(VADriverContextP ctx,
int slice_type = intel_avc_enc_slice_type_fixup(pSliceParameter->slice_type);
int is_intra = slice_type == SLICE_TYPE_I;
int qp_slice;
+ int qp_mb;
qp_slice = qp;
if (rate_control_mode == VA_RC_CBR) {
@@ -1210,19 +1211,26 @@ gen75_mfc_avc_pipeline_slice_programing(VADriverContextP ctx,
y = i / width_in_mbs;
msg = (unsigned int *) (msg_ptr + i * vme_context->vme_output.size_block);
+ if (vme_context->roi_enabled) {
+ qp_mb = *(vme_context->qp_per_mb + i);
+ } else
+ qp_mb = qp;
+
if (is_intra) {
assert(msg);
- gen75_mfc_avc_pak_object_intra(ctx, x, y, last_mb, qp, msg, encoder_context, 0, 0, slice_batch);
+ gen75_mfc_avc_pak_object_intra(ctx, x, y, last_mb, qp_mb, msg, encoder_context, 0, 0, slice_batch);
} else {
int inter_rdo, intra_rdo;
inter_rdo = msg[AVC_INTER_RDO_OFFSET] & AVC_RDO_MASK;
intra_rdo = msg[AVC_INTRA_RDO_OFFSET] & AVC_RDO_MASK;
offset = i * vme_context->vme_output.size_block + AVC_INTER_MV_OFFSET;
if (intra_rdo < inter_rdo) {
- gen75_mfc_avc_pak_object_intra(ctx, x, y, last_mb, qp, msg, encoder_context, 0, 0, slice_batch);
+ gen75_mfc_avc_pak_object_intra(ctx, x, y, last_mb, qp_mb, msg, encoder_context, 0, 0, slice_batch);
} else {
msg += AVC_INTER_MSG_OFFSET;
- gen75_mfc_avc_pak_object_inter(ctx, x, y, last_mb, qp, msg, offset, encoder_context, 0, 0, slice_type, slice_batch);
+ gen75_mfc_avc_pak_object_inter(ctx, x, y, last_mb, qp_mb,
+ msg, offset, encoder_context,
+ 0, 0, slice_type, slice_batch);
}
}
}
diff --git a/src/gen75_vme.c b/src/gen75_vme.c
index 355eb14..6737e80 100644
--- a/src/gen75_vme.c
+++ b/src/gen75_vme.c
@@ -497,6 +497,7 @@ gen75_vme_fill_vme_batchbuffer(VADriverContextP ctx,
VAEncSliceParameterBufferH264 *slice_param = (VAEncSliceParameterBufferH264 *)encode_state->slice_params_ext[0]->buffer;
int qp;
int slice_type = intel_avc_enc_slice_type_fixup(slice_param->slice_type);
+ int qp_mb, qp_index;
if (encoder_context->rate_control_mode == VA_RC_CQP)
qp = pic_param->pic_init_qp + slice_param->slice_qp_delta;
@@ -550,7 +551,12 @@ gen75_vme_fill_vme_batchbuffer(VADriverContextP ctx,
*command_ptr++ = (mb_width << 16 | mb_y << 8 | mb_x);
*command_ptr++ = ((encoder_context->quality_level << 24) | (1 << 16) | transform_8x8_mode_flag | (mb_intra_ub << 8));
/* qp occupies one byte */
- *command_ptr++ = qp;
+ if (vme_context->roi_enabled) {
+ qp_index = mb_y * mb_width + mb_x;
+ qp_mb = *(vme_context->qp_per_mb + qp_index);
+ } else
+ qp_mb = qp;
+ *command_ptr++ = qp_mb;
i += 1;
}
@@ -665,6 +671,8 @@ static VAStatus gen75_vme_prepare(VADriverContextP ctx,
intel_vme_update_mbmv_cost(ctx, encode_state, encoder_context);
intel_h264_initialize_mbmv_cost(ctx, encode_state, encoder_context);
+ intel_h264_enc_roi_config(ctx, encode_state, encoder_context);
+
/*Setup all the memory object*/
gen75_vme_surface_setup(ctx, encode_state, is_intra, encoder_context);
gen75_vme_interface_setup(ctx, encode_state, encoder_context);
--
1.7.10.1
More information about the Libva
mailing list