From: Pengfei Qu <pengfei...@intel.com> Signed-off-by: Pengfei Qu <pengfei...@intel.com> Reviewed-by: Sean V Kelley <sea...@posteo.de> --- src/gen9_avc_encoder.c | 135 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+)
diff --git a/src/gen9_avc_encoder.c b/src/gen9_avc_encoder.c index 65a4bc95..a025f563 100755 --- a/src/gen9_avc_encoder.c +++ b/src/gen9_avc_encoder.c @@ -2483,3 +2483,138 @@ gen9_avc_kernel_brc_frame_update(VADriverContextP ctx, return VA_STATUS_SUCCESS; } + +static void +gen9_avc_set_curbe_brc_mb_update(VADriverContextP ctx, + struct encode_state *encode_state, + struct i965_gpe_context *gpe_context, + struct intel_encoder_context *encoder_context, + void * param) +{ + gen9_avc_mb_brc_curbe_data *cmd; + struct encoder_vme_mfc_context * vme_context = (struct encoder_vme_mfc_context *)encoder_context->vme_context; + struct generic_enc_codec_state * generic_state = (struct generic_enc_codec_state * )vme_context->generic_enc_state; + + cmd = i965_gpe_context_map_curbe(gpe_context); + memset(cmd,0,sizeof(gen9_avc_mb_brc_curbe_data)); + + cmd->dw0.cur_frame_type = generic_state->frame_type; + if(generic_state->brc_roi_enable) + { + cmd->dw0.enable_roi = 1; + }else + { + cmd->dw0.enable_roi = 0; + } + + i965_gpe_context_unmap_curbe(gpe_context); + + return; +} + +static void +gen9_avc_send_surface_brc_mb_update(VADriverContextP ctx, + struct encode_state *encode_state, + struct i965_gpe_context *gpe_context, + struct intel_encoder_context *encoder_context, + void * param_mbenc) +{ + struct encoder_vme_mfc_context * vme_context = (struct encoder_vme_mfc_context *)encoder_context->vme_context; + struct gen9_avc_encoder_context * avc_ctx = (struct gen9_avc_encoder_context * )vme_context->private_enc_ctx; + struct generic_enc_codec_state * generic_state = (struct generic_enc_codec_state * )vme_context->generic_enc_state; + + /* brc history buffer*/ + gen9_add_buffer_gpe_surface(ctx, + gpe_context, + &avc_ctx->res_brc_history_buffer, + 0, + avc_ctx->res_brc_history_buffer.size, + 0, + GEN9_AVC_MB_BRC_UPDATE_HISTORY_INDEX); + + /* MB qp data buffer is it same as res_mbbrc_mb_qp_data_surface*/ + if(generic_state->mb_brc_enabled) + { + gen9_add_buffer_2d_gpe_surface(ctx, + gpe_context, + &avc_ctx->res_mbbrc_mb_qp_data_surface, + 1, + I965_SURFACEFORMAT_R8_UNORM, + GEN9_AVC_MB_BRC_UPDATE_MB_QP_INDEX); + + } + + /* BRC roi feature*/ + if(generic_state->brc_roi_enable) + { + gen9_add_buffer_gpe_surface(ctx, + gpe_context, + &avc_ctx->res_mbbrc_roi_surface, + 0, + avc_ctx->res_mbbrc_roi_surface.size, + 0, + GEN9_AVC_MB_BRC_UPDATE_ROI_INDEX); + + } + + /* MB statistical data surface*/ + gen9_add_buffer_gpe_surface(ctx, + gpe_context, + &avc_ctx->res_mb_status_buffer, + 0, + avc_ctx->res_mb_status_buffer.size, + 0, + GEN9_AVC_MB_BRC_UPDATE_MB_STATUS_INDEX); + + return; +} + +static VAStatus +gen9_avc_kernel_brc_mb_update(VADriverContextP ctx, + struct encode_state *encode_state, + struct intel_encoder_context *encoder_context) + +{ + struct encoder_vme_mfc_context * vme_context = (struct encoder_vme_mfc_context *)encoder_context->vme_context; + struct gen9_avc_encoder_context * avc_ctx = (struct gen9_avc_encoder_context * )vme_context->private_enc_ctx; + struct generic_enc_codec_state * generic_state = (struct generic_enc_codec_state * )vme_context->generic_enc_state; + struct generic_encoder_context * generic_ctx = (struct generic_encoder_context * )vme_context->generic_enc_ctx; + + struct i965_gpe_context *gpe_context; + struct gpe_media_object_walker_parameter media_object_walker_param; + struct gpe_encoder_kernel_walker_parameter kernel_walker_param; + int media_function = 0; + int kernel_idx = 0; + + media_function = INTEL_MEDIA_STATE_MB_BRC_UPDATE; + kernel_idx = GEN9_AVC_KERNEL_BRC_MB_UPDATE; + gpe_context = &(avc_ctx->context_brc.gpe_contexts[kernel_idx]); + + gen8_gpe_context_init(ctx, gpe_context); + gen9_gpe_reset_binding_table(ctx, gpe_context); + + /* set curbe brc mb update*/ + generic_ctx->pfn_set_curbe_brc_mb_update(ctx,encode_state,gpe_context,encoder_context,NULL); + + + /* set surface brc mb update*/ + generic_ctx->pfn_send_brc_mb_update_surface(ctx,encode_state,gpe_context,encoder_context,NULL); + + + gen8_gpe_setup_interface_data(ctx, gpe_context); + + memset(&kernel_walker_param, 0, sizeof(kernel_walker_param)); + /* the scaling is based on 8x8 blk level */ + kernel_walker_param.resolution_x = (generic_state->frame_width_in_mbs + 1)/2; + kernel_walker_param.resolution_y = (generic_state->frame_height_in_mbs + 1)/2 ; + kernel_walker_param.no_dependency = 1; + + i965_init_media_object_walker_parameter(&kernel_walker_param, &media_object_walker_param); + + gen9_avc_run_kernel_media_object_walker(ctx, encoder_context, + gpe_context, + media_function, + &media_object_walker_param); + + return VA_STATUS_SUCCESS; +} -- 2.11.0 _______________________________________________ Libva mailing list Libva@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libva