diff options
author | Xiang, Haihao <haihao.xiang@intel.com> | 2013-03-12 13:25:24 +0800 |
---|---|---|
committer | Xiang, Haihao <haihao.xiang@intel.com> | 2013-03-15 15:45:28 +0800 |
commit | bef3715ea52c696c39d6780f98343d81bf934104 (patch) | |
tree | f709d076422978c9e3666d386d4a719255c12aa5 /src | |
parent | 982dff70c7cd5e804ec0a7b3364704c3cbd00e0c (diff) | |
download | vaapi-intel-driver-bef3715ea52c696c39d6780f98343d81bf934104.tar.gz vaapi-intel-driver-bef3715ea52c696c39d6780f98343d81bf934104.tar.bz2 vaapi-intel-driver-bef3715ea52c696c39d6780f98343d81bf934104.zip |
Encoder: unify the initialization of the context
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/i965_encoder.c | 81 |
1 files changed, 17 insertions, 64 deletions
diff --git a/src/i965_encoder.c b/src/i965_encoder.c index a7334ac..8374548 100644 --- a/src/i965_encoder.c +++ b/src/i965_encoder.c @@ -168,8 +168,13 @@ intel_encoder_context_destroy(void *hw_context) free(encoder_context); } -struct hw_context * -gen6_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config) +typedef Bool (* hw_init_func)(VADriverContextP, struct intel_encoder_context *); + +static struct hw_context * +intel_enc_hw_context_init(VADriverContextP ctx, + struct object_config *obj_config, + hw_init_func vme_context_init, + hw_init_func mfc_context_init) { struct intel_driver_data *intel = intel_driver_data(ctx); struct intel_encoder_context *encoder_context = calloc(1, sizeof(struct intel_encoder_context)); @@ -190,12 +195,12 @@ gen6_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config) } } - gen6_vme_context_init(ctx, encoder_context); + vme_context_init(ctx, encoder_context); assert(encoder_context->vme_context); assert(encoder_context->vme_context_destroy); assert(encoder_context->vme_pipeline); - gen6_mfc_context_init(ctx, encoder_context); + mfc_context_init(ctx, encoder_context); assert(encoder_context->mfc_context); assert(encoder_context->mfc_context_destroy); assert(encoder_context->mfc_pipeline); @@ -204,71 +209,19 @@ gen6_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config) } struct hw_context * -gen7_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config) +gen6_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config) { - struct intel_driver_data *intel = intel_driver_data(ctx); - struct intel_encoder_context *encoder_context = calloc(1, sizeof(struct intel_encoder_context)); - int i; - - encoder_context->base.destroy = intel_encoder_context_destroy; - encoder_context->base.run = intel_encoder_end_picture; - encoder_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0); - encoder_context->input_yuv_surface = VA_INVALID_SURFACE; - encoder_context->is_tmp_id = 0; - encoder_context->rate_control_mode = VA_RC_NONE; - encoder_context->profile = obj_config->profile; - - for (i = 0; i < obj_config->num_attribs; i++) { - if (obj_config->attrib_list[i].type == VAConfigAttribRateControl) { - encoder_context->rate_control_mode = obj_config->attrib_list[i].value; - break; - } - } - - gen7_vme_context_init(ctx, encoder_context); - assert(encoder_context->vme_context); - assert(encoder_context->vme_context_destroy); - assert(encoder_context->vme_pipeline); - - gen7_mfc_context_init(ctx, encoder_context); - assert(encoder_context->mfc_context); - assert(encoder_context->mfc_context_destroy); - assert(encoder_context->mfc_pipeline); + return intel_enc_hw_context_init(ctx, obj_config, gen6_vme_context_init, gen6_mfc_context_init); +} - return (struct hw_context *)encoder_context; +struct hw_context * +gen7_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config) +{ + return intel_enc_hw_context_init(ctx, obj_config, gen7_vme_context_init, gen7_mfc_context_init); } struct hw_context * gen75_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config) { - struct intel_driver_data *intel = intel_driver_data(ctx); - struct intel_encoder_context *encoder_context = calloc(1, sizeof(struct intel_encoder_context)); - int i; - - encoder_context->base.destroy = intel_encoder_context_destroy; - encoder_context->base.run = intel_encoder_end_picture; - encoder_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0); - encoder_context->input_yuv_surface = VA_INVALID_SURFACE; - encoder_context->is_tmp_id = 0; - encoder_context->rate_control_mode = VA_RC_NONE; - encoder_context->profile = obj_config->profile; - - for (i = 0; i < obj_config->num_attribs; i++) { - if (obj_config->attrib_list[i].type == VAConfigAttribRateControl) { - encoder_context->rate_control_mode = obj_config->attrib_list[i].value; - break; - } - } - - gen75_vme_context_init(ctx, encoder_context); - assert(encoder_context->vme_context); - assert(encoder_context->vme_context_destroy); - assert(encoder_context->vme_pipeline); - - gen75_mfc_context_init(ctx, encoder_context); - assert(encoder_context->mfc_context); - assert(encoder_context->mfc_context_destroy); - assert(encoder_context->mfc_pipeline); - - return (struct hw_context *)encoder_context; + return intel_enc_hw_context_init(ctx, obj_config, gen75_vme_context_init, gen75_mfc_context_init); } |