Signed-off-by: Pengfei Qu <pengfei...@intel.com> Reviewed-by: Sean V Kelley<sea...@posteo.de> --- src/Makefile.am | 10 ++++++++++ src/i965_drv_video.c | 8 ++++++-- src/i965_drv_video.h | 2 ++ src/i965_encoder.c | 52 ++++++++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 62 insertions(+), 10 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am index 424812b..e0f3aec 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -101,6 +101,10 @@ source_c = \ gen9_vp9_encoder_kernels.c \ gen9_vp9_const_def.c \ gen9_vp9_encoder.c \ + i965_avc_encoder_common.c \ + i965_encoder_common.c \ + gen9_avc_const_def.c \ + gen9_avc_encoder.c \ intel_common_vpp_internal.c \ $(NULL) @@ -154,6 +158,12 @@ source_h = \ gen9_vp9_encapi.h \ gen9_vp9_const_def.h \ gen9_vp9_encoder_kernels.h \ + i965_encoder_api.h \ + i965_avc_encoder_common.h \ + i965_encoder_common.h \ + gen9_avc_encoder.h \ + gen9_avc_const_def.h \ + gen9_avc_encoder_kernels.h \ intel_gen_vppapi.h \ intel_common_vpp_internal.h \ $(NULL) diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c index cc37190..64cc0e2 100644 --- a/src/i965_drv_video.c +++ b/src/i965_drv_video.c @@ -911,6 +911,7 @@ i965_GetConfigAttributes(VADriverContextP ctx, VAConfigAttrib *attrib_list, /* in/out */ int num_attribs) { + struct i965_driver_data * const i965 = i965_driver_data(ctx); VAStatus va_status; int i; @@ -1003,8 +1004,11 @@ i965_GetConfigAttributes(VADriverContextP ctx, attrib_list[i].value = 1; if (profile == VAProfileH264ConstrainedBaseline || profile == VAProfileH264Main || - profile == VAProfileH264High ) - attrib_list[i].value = ENCODER_QUALITY_RANGE; + profile == VAProfileH264High ){ + attrib_list[i].value = ENCODER_QUALITY_RANGE; + if(IS_GEN9(i965->intel.device_info)) + attrib_list[i].value = ENCODER_QUALITY_RANGE_AVC; + } break; } break; diff --git a/src/i965_drv_video.h b/src/i965_drv_video.h index 7cba3a3..334b788 100644 --- a/src/i965_drv_video.h +++ b/src/i965_drv_video.h @@ -69,7 +69,9 @@ #define DEFAULT_SATURATION 50 #define ENCODER_QUALITY_RANGE 2 +#define ENCODER_QUALITY_RANGE_AVC 8 #define ENCODER_DEFAULT_QUALITY 1 +#define ENCODER_DEFAULT_QUALITY_AVC 4 #define ENCODER_HIGH_QUALITY ENCODER_DEFAULT_QUALITY #define ENCODER_LOW_QUALITY 2 diff --git a/src/i965_encoder.c b/src/i965_encoder.c index 0a648d4..6a32a3f 100644 --- a/src/i965_encoder.c +++ b/src/i965_encoder.c @@ -41,6 +41,7 @@ #include "gen6_mfc.h" #include "i965_post_processing.h" +#include "i965_encoder_api.h" static struct intel_fraction reduce_fraction(struct intel_fraction f) @@ -789,9 +790,11 @@ intel_encoder_check_temporal_layer_structure(VADriverContextP ctx, static VAStatus intel_encoder_check_misc_parameter(VADriverContextP ctx, + VAProfile profile, struct encode_state *encode_state, struct intel_encoder_context *encoder_context) { + struct i965_driver_data *i965 = i965_driver_data(ctx); VAStatus ret = VA_STATUS_SUCCESS; if (encode_state->misc_param[VAEncMiscParameterTypeQualityLevel][0] && @@ -800,12 +803,31 @@ intel_encoder_check_misc_parameter(VADriverContextP ctx, VAEncMiscParameterBufferQualityLevel* param_quality_level = (VAEncMiscParameterBufferQualityLevel*)pMiscParam->data; encoder_context->quality_level = param_quality_level->quality_level; - if (encoder_context->quality_level == 0) - encoder_context->quality_level = ENCODER_DEFAULT_QUALITY; - else if (encoder_context->quality_level > encoder_context->quality_range) { - ret = VA_STATUS_ERROR_INVALID_PARAMETER; - goto out; + switch (profile) { + case VAProfileH264ConstrainedBaseline: + case VAProfileH264Main: + case VAProfileH264High: + if (IS_SKL(i965->intel.device_info)) + { + if (encoder_context->quality_level == 0) + encoder_context->quality_level = ENCODER_DEFAULT_QUALITY_AVC; + } + else + { + if (encoder_context->quality_level == 0) + encoder_context->quality_level = ENCODER_DEFAULT_QUALITY; + } + break; + default: + if (encoder_context->quality_level == 0) + encoder_context->quality_level = ENCODER_DEFAULT_QUALITY; + break; } + + if (encoder_context->quality_level > encoder_context->quality_range) { + ret = VA_STATUS_ERROR_INVALID_PARAMETER; + goto out; + } } ret = intel_encoder_check_temporal_layer_structure(ctx, encode_state, encoder_context); @@ -1281,7 +1303,7 @@ intel_encoder_sanity_check_input(VADriverContextP ctx, } if (vaStatus == VA_STATUS_SUCCESS) - vaStatus = intel_encoder_check_misc_parameter(ctx, encode_state, encoder_context); + vaStatus = intel_encoder_check_misc_parameter(ctx, profile, encode_state, encoder_context); out: return vaStatus; @@ -1362,6 +1384,7 @@ intel_enc_hw_context_init(VADriverContextP ctx, hw_init_func vme_context_init, hw_init_func mfc_context_init) { + struct i965_driver_data *i965 = i965_driver_data(ctx); struct intel_driver_data *intel = intel_driver_data(ctx); struct intel_encoder_context *encoder_context = calloc(1, sizeof(struct intel_encoder_context)); int i; @@ -1394,7 +1417,9 @@ intel_enc_hw_context_init(VADriverContextP ctx, encoder_context->codec = CODEC_H264; if (obj_config->entrypoint == VAEntrypointEncSliceLP) - encoder_context->quality_range = ENCODER_LP_QUALITY_RANGE; + encoder_context->quality_range = ENCODER_QUALITY_RANGE_AVC; + else if(IS_SKL(i965->intel.device_info)) + encoder_context->quality_range = ENCODER_QUALITY_RANGE_AVC; else encoder_context->quality_range = ENCODER_QUALITY_RANGE; break; @@ -1485,5 +1510,16 @@ gen8_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config) struct hw_context * gen9_enc_hw_context_init(VADriverContextP ctx, struct object_config *obj_config) { - return intel_enc_hw_context_init(ctx, obj_config, gen9_vme_context_init, gen9_mfc_context_init); + struct i965_driver_data *i965 = i965_driver_data(ctx); + switch (obj_config->profile){ + case VAProfileH264ConstrainedBaseline: + case VAProfileH264Main: + case VAProfileH264High: + if (IS_SKL(i965->intel.device_info)) + return intel_enc_hw_context_init(ctx, obj_config, gen9_avc_vme_context_init, gen9_avc_pak_context_init); + else + return intel_enc_hw_context_init(ctx, obj_config, gen9_vme_context_init, gen9_mfc_context_init); + default: + return intel_enc_hw_context_init(ctx, obj_config, gen9_vme_context_init, gen9_mfc_context_init); + } } -- 2.7.4 _______________________________________________ Libva mailing list Libva@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libva