v1:
add AVC encoder support on APL

Signed-off-by: Pengfei Qu <pengfei...@intel.com>
Reviewed-by: Sean V Kelley<sea...@posteo.de>
---
 src/gen9_avc_encoder.c |  3 ++-
 src/i965_drv_video.c   |  8 ++++++--
 src/i965_drv_video.h   |  2 ++
 src/i965_encoder.c     | 55 ++++++++++++++++++++++++++++++++++++++++++--------
 4 files changed, 57 insertions(+), 11 deletions(-)

diff --git a/src/gen9_avc_encoder.c b/src/gen9_avc_encoder.c
index 733a5d6..54e2a55 100644
--- a/src/gen9_avc_encoder.c
+++ b/src/gen9_avc_encoder.c
@@ -7366,7 +7366,8 @@ gen9_avc_vme_context_init(VADriverContextP ctx, struct 
intel_encoder_context *en
     vme_context->generic_enc_state = generic_state;
     vme_context->private_enc_state = avc_state;
 
-    if (IS_SKL(i965->intel.device_info)) {
+    if (IS_SKL(i965->intel.device_info)||
+        IS_BXT(i965->intel.device_info)) {
         generic_ctx->enc_kernel_ptr = (void *)skl_avc_encoder_kernels;
         generic_ctx->enc_kernel_size = sizeof(skl_avc_encoder_kernels);
     }
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..0a3ff52 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,32 @@ 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)||
+                IS_BXT(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 +1304,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 +1385,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 +1418,10 @@ 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)||
+                IS_BXT(i965->intel.device_info))
+            encoder_context->quality_range = ENCODER_QUALITY_RANGE_AVC;
         else
             encoder_context->quality_range = ENCODER_QUALITY_RANGE;
         break;
@@ -1485,5 +1512,17 @@ 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)||
+            IS_BXT(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.9.3

_______________________________________________
Libva mailing list
Libva@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libva

Reply via email to