[Libva] [PATCH Libva-intel-driver 02/18] Encoding: Add one function that initialize mbmv cost table for supported Qp range
Zhao, Yakui
yakui.zhao at intel.com
Mon Jan 12 05:01:25 PST 2015
From: Zhao Yakui <yakui.zhao at intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao at intel.com>
---
src/gen6_mfc_common.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++
src/gen6_vme.h | 10 ++++++++++
2 files changed, 63 insertions(+)
diff --git a/src/gen6_mfc_common.c b/src/gen6_mfc_common.c
index 95e227c..4e8f1ad 100644
--- a/src/gen6_mfc_common.c
+++ b/src/gen6_mfc_common.c
@@ -1662,3 +1662,56 @@ void intel_avc_slice_insert_packed_data(VADriverContextP ctx,
return;
}
+void
+intel_h264_initialize_mbmv_cost(VADriverContextP ctx,
+ struct encode_state *encode_state,
+ struct intel_encoder_context *encoder_context)
+{
+ struct i965_driver_data *i965 = i965_driver_data(ctx);
+ struct gen6_vme_context *vme_context = encoder_context->vme_context;
+ VAEncSliceParameterBufferH264 *slice_param = (VAEncSliceParameterBufferH264 *)encode_state->slice_params_ext[0]->buffer;
+ int qp;
+ dri_bo *bo;
+ uint8_t *cost_table;
+
+ int slice_type = intel_avc_enc_slice_type_fixup(slice_param->slice_type);
+
+
+ if (slice_type == SLICE_TYPE_I) {
+ if (vme_context->i_qp_cost_table)
+ return;
+ } else if (slice_type == SLICE_TYPE_P) {
+ if (vme_context->p_qp_cost_table)
+ return;
+ } else {
+ if (vme_context->b_qp_cost_table)
+ return;
+ }
+
+ /* It is enough to allocate 32 bytes for each qp. */
+ bo = dri_bo_alloc(i965->intel.bufmgr,
+ "cost_table ",
+ QP_MAX * 32,
+ 64);
+
+ dri_bo_map(bo, 1);
+
+ cost_table = (uint8_t *)(bo->virtual);
+ for (qp = 0; qp < QP_MAX; qp++) {
+ intel_h264_calc_mbmvcost_qp(qp, slice_type, cost_table);
+ cost_table += 32;
+ }
+
+ dri_bo_unmap(bo);
+
+ if (slice_type == SLICE_TYPE_I) {
+ vme_context->i_qp_cost_table = bo;
+ } else if (slice_type == SLICE_TYPE_P) {
+ vme_context->p_qp_cost_table = bo;
+ } else {
+ vme_context->b_qp_cost_table = bo;
+ }
+
+ vme_context->cost_table_size = QP_MAX * 32;
+ return;
+}
diff --git a/src/gen6_vme.h b/src/gen6_vme.h
index bc62c14..aef9ba6 100644
--- a/src/gen6_vme.h
+++ b/src/gen6_vme.h
@@ -90,6 +90,11 @@ struct gen6_vme_context
struct object_surface *used_reference_objects[2];
void *used_references[2];
unsigned int ref_index_in_mb[2];
+
+ dri_bo *i_qp_cost_table;
+ dri_bo *p_qp_cost_table;
+ dri_bo *b_qp_cost_table;
+ int cost_table_size;
};
#define MPEG2_PIC_WIDTH_HEIGHT 30
@@ -177,4 +182,9 @@ intel_avc_vme_reference_state(VADriverContextP ctx,
extern Bool gen8_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
extern Bool gen9_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
+
+extern void
+intel_h264_initialize_mbmv_cost(VADriverContextP ctx,
+ struct encode_state *encode_state,
+ struct intel_encoder_context *encoder_context);
#endif /* _GEN6_VME_H_ */
--
1.7.10.1
More information about the Libva
mailing list