OSDN Git Service

Don't check the stride in the y direction for a single plane surface
[android-x86/hardware-intel-common-vaapi.git] / src / i965_drv_video.c
index 2405c3b..33316e5 100644 (file)
@@ -973,13 +973,16 @@ i965_GetConfigAttributes(VADriverContextP ctx,
                     profile != VAProfileMPEG2Simple)
                     attrib_list[i].value |= VA_RC_CBR;
 
-                if (profile == VAProfileVP9Profile0 ||
-                    profile == VAProfileH264ConstrainedBaseline ||
-                    profile == VAProfileH264Main ||
-                    profile == VAProfileH264High ||
+                if (profile == VAProfileVP8Version0_3 ||
+                    profile == VAProfileVP9Profile0 ||
                     profile == VAProfileHEVCMain)
                     attrib_list[i].value |= VA_RC_VBR;
 
+                if (profile == VAProfileH264ConstrainedBaseline ||
+                    profile == VAProfileH264Main ||
+                    profile == VAProfileH264High)
+                    attrib_list[i].value = i965->codec_info->h264_brc_mode;
+
                 break;
             } else if (entrypoint == VAEntrypointEncSliceLP) {
                 struct i965_driver_data * const i965 = i965_driver_data(ctx);
@@ -1019,9 +1022,17 @@ i965_GetConfigAttributes(VADriverContextP ctx,
             break;
 
         case VAConfigAttribEncMaxRefFrames:
-            if (entrypoint == VAEntrypointEncSlice)
+            if (entrypoint == VAEntrypointEncSlice) {
                 attrib_list[i].value = (1 << 16) | (1 << 0);
-            else if (entrypoint == VAEntrypointEncSliceLP) {
+                if (profile == VAProfileH264ConstrainedBaseline ||
+                    profile == VAProfileH264Main ||
+                    profile == VAProfileH264High ||
+                    profile == VAProfileH264StereoHigh ||
+                    profile == VAProfileH264MultiviewHigh) {
+                    if (IS_GEN9(i965->intel.device_info))
+                        attrib_list[i].value = (2 << 16) | (8 << 0);
+                }
+            } else if (entrypoint == VAEntrypointEncSliceLP) {
                 /* Don't support B frame for low power mode */
                 if (profile == VAProfileH264ConstrainedBaseline ||
                     profile == VAProfileH264Main ||
@@ -1073,6 +1084,8 @@ i965_GetConfigAttributes(VADriverContextP ctx,
         case VAConfigAttribEncROI:
             if (entrypoint == VAEntrypointEncSlice ||
                 entrypoint == VAEntrypointEncSliceLP) {
+                VAConfigAttribValEncROI *roi_config =
+                    (VAConfigAttribValEncROI *) & (attrib_list[i].value);
 
                 if (profile == VAProfileH264ConstrainedBaseline ||
                     profile == VAProfileH264Main ||
@@ -1082,10 +1095,6 @@ i965_GetConfigAttributes(VADriverContextP ctx,
                         entrypoint == VAEntrypointEncSlice)
                         attrib_list[i].value = 0;
                     else {
-
-                        VAConfigAttribValEncROI *roi_config =
-                            (VAConfigAttribValEncROI *) & (attrib_list[i].value);
-
                         if (entrypoint == VAEntrypointEncSliceLP) {
                             roi_config->bits.num_roi_regions = 3;
                             roi_config->bits.roi_rc_priority_support = 0;
@@ -1097,6 +1106,12 @@ i965_GetConfigAttributes(VADriverContextP ctx,
                             roi_config->bits.roi_rc_qp_delat_support = 1;
                         }
                     }
+                } else if (profile == VAProfileHEVCMain ||
+                           profile == VAProfileHEVCMain10) {
+                    roi_config->bits.num_roi_regions =
+                        I965_MAX_NUM_ROI_REGIONS;
+                    roi_config->bits.roi_rc_priority_support = 1;
+                    roi_config->bits.roi_rc_qp_delat_support = 1;
                 } else {
                     attrib_list[i].value = 0;
                 }
@@ -1124,19 +1139,17 @@ i965_GetConfigAttributes(VADriverContextP ctx,
             break;
 
         case VAConfigAttribEncMaxSlices:
+            attrib_list[i].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_list[i].value = 1;
-                    else
-                        attrib_list[i].value = I965_MAX_NUM_SLICE;
+                    attrib_list[i].value = I965_MAX_NUM_SLICE;
                 } else if (profile == VAProfileHEVCMain ||
                            profile == VAProfileHEVCMain10) {
-                    attrib_list[i].value = 1;
+                    attrib_list[i].value = I965_MAX_NUM_SLICE;
                 }
             } else if (entrypoint == VAEntrypointEncSliceLP) {
                 if ((profile == VAProfileH264ConstrainedBaseline ||
@@ -1145,11 +1158,25 @@ i965_GetConfigAttributes(VADriverContextP ctx,
                     profile == VAProfileH264StereoHigh ||
                     profile == VAProfileH264MultiviewHigh)
                     attrib_list[i].value = I965_MAX_NUM_SLICE;
-            } else
-                attrib_list[i].value = VA_ATTRIB_NOT_SUPPORTED;
+            }
 
             break;
 
+        case VAConfigAttribEncSliceStructure:
+            attrib_list[i].value = VA_ATTRIB_NOT_SUPPORTED;
+            if (entrypoint == VAEntrypointEncSlice) {
+                if ((profile == VAProfileH264ConstrainedBaseline ||
+                     profile == VAProfileH264Main ||
+                     profile == VAProfileH264High) ||
+                    profile == VAProfileH264StereoHigh ||
+                    profile == VAProfileH264MultiviewHigh ||
+                    profile == VAProfileHEVCMain ||
+                    profile == VAProfileHEVCMain10) {
+                    attrib_list[i].value = VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS;
+                }
+            }
+
+            break;
         default:
             /* Do nothing */
             attrib_list[i].value = VA_ATTRIB_NOT_SUPPORTED;
@@ -1246,7 +1273,8 @@ i965_CreateConfig(VADriverContextP ctx,
 
     for (i = 0; i < num_attribs; i++) {
         // add it later and ignore the user input for VAConfigAttribEncMaxSlices
-        if (attrib_list[i].type == VAConfigAttribEncMaxSlices)
+        if (attrib_list[i].type == VAConfigAttribEncMaxSlices ||
+            attrib_list[i].type == VAConfigAttribEncSliceStructure)
             continue;
         vaStatus = i965_ensure_config_attribute(obj_config, &attrib_list[i]);
         if (vaStatus != VA_STATUS_SUCCESS)
@@ -1274,14 +1302,10 @@ i965_CreateConfig(VADriverContextP ctx,
                  profile == VAProfileH264High) ||
                 profile == VAProfileH264StereoHigh ||
                 profile == VAProfileH264MultiviewHigh) {
-                if (IS_GEN9(i965->intel.device_info))
-                    attrib.value = 1;
-                else
-                    attrib.value = I965_MAX_NUM_SLICE;
+                attrib.value = I965_MAX_NUM_SLICE;
             } else if (profile == VAProfileHEVCMain ||
-                       profile == VAProfileHEVCMain10) {
-                attrib.value = 1;
-            }
+                       profile == VAProfileHEVCMain10)
+                attrib.value = I965_MAX_NUM_SLICE;
         } else if (entrypoint == VAEntrypointEncSliceLP) {
             if ((profile == VAProfileH264ConstrainedBaseline ||
                  profile == VAProfileH264Main ||
@@ -1289,8 +1313,25 @@ i965_CreateConfig(VADriverContextP ctx,
                 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) {
+        VAConfigAttrib attrib;
+        attrib.type = VAConfigAttribEncSliceStructure;
+        attrib.value = VA_ATTRIB_NOT_SUPPORTED;
+        if (entrypoint == VAEntrypointEncSlice) {
+            if ((profile == VAProfileH264ConstrainedBaseline ||
+                 profile == VAProfileH264Main ||
+                 profile == VAProfileH264High) ||
+                profile == VAProfileH264StereoHigh ||
+                profile == VAProfileH264MultiviewHigh) {
+                attrib.value = VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS;
+            }
+        }
 
         if (attrib.value != VA_ATTRIB_NOT_SUPPORTED)
             vaStatus = i965_append_config_attribute(obj_config, &attrib);
@@ -1441,6 +1482,11 @@ i965_suface_external_memory(VADriverContextP ctx,
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     unsigned int tiling, swizzle;
 
+    if (!memory_attibute ||
+        !memory_attibute->buffers ||
+        index >= memory_attibute->num_buffers)
+        return VA_STATUS_ERROR_INVALID_PARAMETER;
+
     obj_surface->size = memory_attibute->data_size;
     if (external_memory_type == I965_SURFACE_MEM_GEM_FLINK)
         obj_surface->bo = drm_intel_bo_gem_create_from_name(i965->intel.bufmgr,
@@ -1455,10 +1501,6 @@ i965_suface_external_memory(VADriverContextP ctx,
         return VA_STATUS_ERROR_INVALID_PARAMETER;
 
     dri_bo_get_tiling(obj_surface->bo, &tiling, &swizzle);
-    if (!memory_attibute ||
-        !memory_attibute->buffers ||
-        index > memory_attibute->num_buffers)
-        return VA_STATUS_ERROR_INVALID_PARAMETER;
 
     ASSERT_RET(obj_surface->orig_width == memory_attibute->width, VA_STATUS_ERROR_INVALID_PARAMETER);
     ASSERT_RET(obj_surface->orig_height == memory_attibute->height, VA_STATUS_ERROR_INVALID_PARAMETER);
@@ -1474,15 +1516,22 @@ i965_suface_external_memory(VADriverContextP ctx,
         obj_surface->height = memory_attibute->data_size / obj_surface->width;
     else
         obj_surface->height = memory_attibute->offsets[1] / obj_surface->width;
-    ASSERT_RET(IS_ALIGNED(obj_surface->height, 16), VA_STATUS_ERROR_INVALID_PARAMETER);
-    ASSERT_RET(obj_surface->height >= obj_surface->orig_height, VA_STATUS_ERROR_INVALID_PARAMETER);
+
+    if (memory_attibute->num_planes > 1) {
+        ASSERT_RET(IS_ALIGNED(obj_surface->height, 16), VA_STATUS_ERROR_INVALID_PARAMETER);
+        ASSERT_RET(obj_surface->height >= obj_surface->orig_height, VA_STATUS_ERROR_INVALID_PARAMETER);
+    }
 
     if (tiling) {
         ASSERT_RET(IS_ALIGNED(obj_surface->width, 128), VA_STATUS_ERROR_INVALID_PARAMETER);
-        ASSERT_RET(IS_ALIGNED(obj_surface->height, 32), VA_STATUS_ERROR_INVALID_PARAMETER);
+
+        if (memory_attibute->num_planes > 1)
+            ASSERT_RET(IS_ALIGNED(obj_surface->height, 32), VA_STATUS_ERROR_INVALID_PARAMETER);
     } else {
         ASSERT_RET(IS_ALIGNED(obj_surface->width, i965->codec_info->min_linear_wpitch), VA_STATUS_ERROR_INVALID_PARAMETER);
-        ASSERT_RET(IS_ALIGNED(obj_surface->height, i965->codec_info->min_linear_hpitch), VA_STATUS_ERROR_INVALID_PARAMETER);
+
+        if (memory_attibute->num_planes > 1)
+            ASSERT_RET(IS_ALIGNED(obj_surface->height, i965->codec_info->min_linear_hpitch), VA_STATUS_ERROR_INVALID_PARAMETER);
     }
 
     obj_surface->x_cb_offset = 0; /* X offset is always 0 */
@@ -2285,6 +2334,7 @@ i965_destroy_context(struct object_heap *heap, struct object_base *obj)
 
         i965_release_buffer_store(&obj_context->codec_state.decode.pic_param);
         i965_release_buffer_store(&obj_context->codec_state.decode.iq_matrix);
+        i965_release_buffer_store(&obj_context->codec_state.decode.huffman_table);
         i965_release_buffer_store(&obj_context->codec_state.decode.bit_plane);
 
         for (i = 0; i < obj_context->codec_state.decode.num_slice_params; i++)