From: Zhao Yakui <yakui.z...@intel.com> Signed-off-by: Zhao Yakui <yakui.zh...@intel.com> Signed-off-by: pjl <ceciliap...@intel.com> Signed-off-by: Pengfei Qu <pengfei...@intel.com> --- src/gen6_mfc_common.c | 104 ++++++++++++++++++++++++++++++++++++++++---------- src/gen6_vme.h | 15 +++++++- 2 files changed, 98 insertions(+), 21 deletions(-)
diff --git a/src/gen6_mfc_common.c b/src/gen6_mfc_common.c index f961ecd..bb02c83 100644 --- a/src/gen6_mfc_common.c +++ b/src/gen6_mfc_common.c @@ -765,29 +765,14 @@ static float intel_lambda_qp(int qp) } -void intel_vme_update_mbmv_cost(VADriverContextP ctx, - struct encode_state *encode_state, - struct intel_encoder_context *encoder_context) +static +void intel_h264_calc_mbmvcost_qp(int qp, + int slice_type, + uint8_t *vme_state_message) { - struct gen6_mfc_context *mfc_context = encoder_context->mfc_context; - struct gen6_vme_context *vme_context = encoder_context->vme_context; - VAEncPictureParameterBufferH264 *pic_param = (VAEncPictureParameterBufferH264 *)encode_state->pic_param_ext->buffer; - VAEncSliceParameterBufferH264 *slice_param = (VAEncSliceParameterBufferH264 *)encode_state->slice_params_ext[0]->buffer; - int qp, m_cost, j, mv_count; - uint8_t *vme_state_message = (uint8_t *)(vme_context->vme_state_message); + int m_cost, j, mv_count; float lambda, m_costf; - int slice_type = intel_avc_enc_slice_type_fixup(slice_param->slice_type); - - - if (encoder_context->rate_control_mode == VA_RC_CQP) - qp = pic_param->pic_init_qp + slice_param->slice_qp_delta; - else - qp = mfc_context->bit_rate_control_context[slice_type].QpPrimeY; - - if (vme_state_message == NULL) - return; - assert(qp <= QP_MAX); lambda = intel_lambda_qp(qp); if (slice_type == SLICE_TYPE_I) { @@ -875,6 +860,31 @@ void intel_vme_update_mbmv_cost(VADriverContextP ctx, vme_state_message[MODE_INTER_BWD] = intel_format_lutvalue(m_cost, 0x6f); } } + return; +} + +void intel_vme_update_mbmv_cost(VADriverContextP ctx, + struct encode_state *encode_state, + struct intel_encoder_context *encoder_context) +{ + struct gen6_mfc_context *mfc_context = encoder_context->mfc_context; + struct gen6_vme_context *vme_context = encoder_context->vme_context; + VAEncPictureParameterBufferH264 *pic_param = (VAEncPictureParameterBufferH264 *)encode_state->pic_param_ext->buffer; + VAEncSliceParameterBufferH264 *slice_param = (VAEncSliceParameterBufferH264 *)encode_state->slice_params_ext[0]->buffer; + int qp; + uint8_t *vme_state_message = (uint8_t *)(vme_context->vme_state_message); + + int slice_type = intel_avc_enc_slice_type_fixup(slice_param->slice_type); + + if (encoder_context->rate_control_mode == VA_RC_CQP) + qp = pic_param->pic_init_qp + slice_param->slice_qp_delta; + else + qp = mfc_context->bit_rate_control_context[slice_type].QpPrimeY; + + if (vme_state_message == NULL) + return; + + intel_h264_calc_mbmvcost_qp(qp, slice_type, vme_state_message); } void intel_vme_vp8_update_mbmv_cost(VADriverContextP ctx, @@ -1636,6 +1646,60 @@ 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; +} + /* HEVC */ static int hevc_temporal_find_surface(VAPictureHEVC *curr_pic, diff --git a/src/gen6_vme.h b/src/gen6_vme.h index dc568ac..ea9918b 100644 --- a/src/gen6_vme.h +++ b/src/gen6_vme.h @@ -1,5 +1,5 @@ /* - * Copyright ? 2009 Intel Corporation + * Copyright <A9> 2009 Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the @@ -46,6 +46,8 @@ #define GEN6_VME_KERNEL_NUMBER 3 +#define INTEL_COST_TABLE_OFFSET 8 + struct encode_state; struct intel_encoder_context; @@ -91,6 +93,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 @@ -200,4 +207,10 @@ void intel_vme_hevc_update_mbmv_cost(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_ */ -- 2.7.4
_______________________________________________ Libva mailing list Libva@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libva