OSDN Git Service

ENC: Add the attribute of VAConfigAttribEncMaxSlices for AVC/HEVC encoder
authorPengfei Qu <Pengfei.Qu@intel.com>
Wed, 5 Apr 2017 09:28:23 +0000 (17:28 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Thu, 6 Apr 2017 12:01:49 +0000 (20:01 +0800)
this patch enable the VAConfigAttribEncMaxSlices attribute and
this also add WA to disable multi slcie feature on APL/KBL/SKL as the improved AVC encoder does not support it.

Fixes #117

Signed-off-by: Pengfei Qu <Pengfei.Qu@intel.com>
src/i965_drv_video.c
src/i965_drv_video.h
src/i965_encoder.c
src/i965_encoder.h

index 2fb68e5..ff309ee 100644 (file)
@@ -1078,6 +1078,33 @@ i965_GetConfigAttributes(VADriverContextP ctx,
 
             break;
 
+        case VAConfigAttribEncMaxSlices:
+            if (entrypoint == VAEntrypointEncSlice) {
+                if ((profile == VAProfileH264ConstrainedBaseline ||
+                    profile == VAProfileH264Main ||
+                    profile == VAProfileH264High) ||
+                    profile == VAProfileH264StereoHigh ||
+                    profile == VAProfileH264MultiviewHigh) {
+                        if (IS_GEN9(i965->intel.device_info))
+                            attrib_list[i].value = 1;
+                        else
+                            attrib_list[i].value = I965_MAX_NUM_SLICE;
+                }else if (profile == VAProfileHEVCMain ||
+                    profile == VAProfileHEVCMain10) {
+                        attrib_list[i].value = I965_MAX_NUM_SLICE;
+                }
+            } else if (entrypoint == VAEntrypointEncSliceLP) {
+                if ((profile == VAProfileH264ConstrainedBaseline ||
+                    profile == VAProfileH264Main ||
+                    profile == VAProfileH264High) ||
+                    profile == VAProfileH264StereoHigh ||
+                    profile == VAProfileH264MultiviewHigh)
+                    attrib_list[i].value = I965_MAX_NUM_SLICE;
+            } else
+                attrib_list[i].value = VA_ATTRIB_NOT_SUPPORTED;
+
+            break;
+
         default:
             /* Do nothing */
             attrib_list[i].value = VA_ATTRIB_NOT_SUPPORTED;
@@ -1173,6 +1200,9 @@ i965_CreateConfig(VADriverContextP ctx,
     obj_config->wrapper_config = VA_INVALID_ID;
 
     for (i = 0; i < num_attribs; i++) {
+        // add it later and ignore the user input for VAConfigAttribEncMaxSlices
+        if(attrib_list[i].type == VAConfigAttribEncMaxSlices)
+            continue;
         vaStatus = i965_ensure_config_attribute(obj_config, &attrib_list[i]);
         if (vaStatus != VA_STATUS_SUCCESS)
             break;
@@ -1189,6 +1219,38 @@ i965_CreateConfig(VADriverContextP ctx,
             vaStatus = VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
     }
 
+    if (vaStatus == VA_STATUS_SUCCESS) {
+        VAConfigAttrib attrib;
+        attrib.type = VAConfigAttribEncMaxSlices;
+        attrib.value = VA_ATTRIB_NOT_SUPPORTED;
+        if (entrypoint == VAEntrypointEncSlice) {
+            if ((profile == VAProfileH264ConstrainedBaseline ||
+                profile == VAProfileH264Main ||
+                profile == VAProfileH264High) ||
+                profile == VAProfileH264StereoHigh ||
+                profile == VAProfileH264MultiviewHigh) {
+                    if (IS_GEN9(i965->intel.device_info))
+                        attrib.value = 1;
+                    else
+                        attrib.value = I965_MAX_NUM_SLICE;
+            }else if (profile == VAProfileHEVCMain ||
+                profile == VAProfileHEVCMain10) {
+                attrib.value = I965_MAX_NUM_SLICE;
+            }
+        } else if (entrypoint == VAEntrypointEncSliceLP) {
+            if ((profile == VAProfileH264ConstrainedBaseline ||
+                profile == VAProfileH264Main ||
+                profile == VAProfileH264High) ||
+                profile == VAProfileH264StereoHigh ||
+                profile == VAProfileH264MultiviewHigh)
+                attrib.value = I965_MAX_NUM_SLICE;
+        } else
+            attrib.value = VA_ATTRIB_NOT_SUPPORTED;
+
+        if(attrib.value != VA_ATTRIB_NOT_SUPPORTED)
+            vaStatus = i965_append_config_attribute(obj_config, &attrib);
+    }
+
     if ((vaStatus == VA_STATUS_SUCCESS) &&
         (profile == VAProfileVP9Profile0) &&
         (entrypoint == VAEntrypointVLD) &&
index 334b788..8485426 100644 (file)
@@ -76,6 +76,7 @@
 #define ENCODER_LOW_QUALITY       2
 
 #define I965_MAX_NUM_ROI_REGIONS                     8
+#define I965_MAX_NUM_SLICE                           32
 
 #define ENCODER_LP_QUALITY_RANGE  8
 
index ea2f949..9839f06 100644 (file)
@@ -857,6 +857,9 @@ intel_encoder_check_avc_parameter(VADriverContextP ctx,
     if (!obj_buffer || !obj_buffer->buffer_store || !obj_buffer->buffer_store->bo)
         goto error;
 
+    if (encode_state->num_slice_params_ext > encoder_context->max_slice_or_seg_num )
+        goto error;
+
     encode_state->coded_buf_object = obj_buffer;
 
     for (i = 0; i < 16; i++) {
@@ -1102,6 +1105,9 @@ intel_encoder_check_hevc_parameter(VADriverContextP ctx,
     if (!obj_buffer || !obj_buffer->buffer_store || !obj_buffer->buffer_store->bo)
         goto error;
 
+    if (encode_state->num_slice_params_ext > encoder_context->max_slice_or_seg_num )
+        goto error;
+
     encode_state->coded_buf_object = obj_buffer;
 
     for (i = 0; i < 15; i++) {
@@ -1387,6 +1393,7 @@ intel_enc_hw_context_init(VADriverContextP ctx,
     encoder_context->quality_level = ENCODER_DEFAULT_QUALITY;
     encoder_context->quality_range = 1;
     encoder_context->layer.num_layers = 1;
+    encoder_context->max_slice_or_seg_num = 1;
 
     if (obj_config->entrypoint == VAEntrypointEncSliceLP)
         encoder_context->low_power_mode = 1;
@@ -1460,6 +1467,11 @@ intel_enc_hw_context_init(VADriverContextP ctx,
             if (encoder_context->codec == CODEC_H264)
                 encoder_context->context_roi = 1;
         }
+        if (obj_config->attrib_list[i].type == VAConfigAttribEncMaxSlices) {
+            if (encoder_context->codec == CODEC_H264 ||
+                encoder_context->codec == CODEC_HEVC)
+                encoder_context->max_slice_or_seg_num = obj_config->attrib_list[i].value;
+        }
     }
 
     if (vme_context_init) {
index 829df9d..a6c6b5a 100644 (file)
@@ -72,6 +72,7 @@ struct intel_encoder_context
     unsigned int num_frames_in_sequence;
     unsigned int frame_width_in_pixel;
     unsigned int frame_height_in_pixel;
+    unsigned int max_slice_or_seg_num;
 
     struct {
         unsigned int num_layers;