OSDN Git Service

Do not return FEI caps for non-FEI entrypoints
[android-x86/hardware-intel-common-vaapi.git] / src / i965_drv_video.c
index aca72a8..e206a2f 100644 (file)
@@ -583,7 +583,8 @@ i965_QueryConfigProfiles(VADriverContextP ctx,
     }
 
     if (HAS_VP9_DECODING_PROFILE(i965, VAProfileVP9Profile0) ||
-        HAS_VP9_ENCODING(i965)) {
+        HAS_VP9_ENCODING(i965) ||
+        HAS_LP_VP9_ENCODING(i965)) {
         profile_list[i++] = VAProfileVP9Profile0;
     }
 
@@ -720,6 +721,9 @@ i965_QueryConfigEntrypoints(VADriverContextP ctx,
         if (HAS_VP9_ENCODING(i965) && (profile == VAProfileVP9Profile0))
             entrypoint_list[n++] = VAEntrypointEncSlice;
 
+        if (HAS_LP_VP9_ENCODING(i965) && (profile == VAProfileVP9Profile0))
+            entrypoint_list[n++] = VAEntrypointEncSliceLP;
+
         if (profile == VAProfileVP9Profile0) {
             if (i965->wrapper_pdrvctx) {
                 VAStatus va_status = VA_STATUS_SUCCESS;
@@ -877,12 +881,18 @@ i965_validate_config(VADriverContextP ctx, VAProfile profile,
         } else if ((HAS_VP9_ENCODING_PROFILE(i965, profile)) &&
                    (entrypoint == VAEntrypointEncSlice)) {
             va_status = VA_STATUS_SUCCESS;
+        } else if ((HAS_LP_VP9_ENCODING(i965) &&
+                    profile == VAProfileVP9Profile0 &&
+                    entrypoint == VAEntrypointEncSliceLP)) {
+            va_status = VA_STATUS_SUCCESS;
         } else if (profile == VAProfileVP9Profile0 &&
                    entrypoint == VAEntrypointVLD &&
                    i965->wrapper_pdrvctx) {
             va_status = VA_STATUS_SUCCESS;
         } else if (!HAS_VP9_DECODING_PROFILE(i965, profile) &&
-                   !HAS_VP9_ENCODING(i965) && !i965->wrapper_pdrvctx) {
+                   !HAS_VP9_ENCODING(i965) &&
+                   !HAS_LP_VP9_ENCODING(i965) &&
+                   !i965->wrapper_pdrvctx) {
             va_status = VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
         } else {
             va_status = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
@@ -968,10 +978,13 @@ i965_get_rc_attributes(VADriverContextP ctx, VAProfile profile, VAEntrypoint ent
             rc_attribs |= VA_RC_CBR;
 
         if (profile == VAProfileVP8Version0_3 ||
-            profile == VAProfileVP9Profile0 ||
-            profile == VAProfileHEVCMain)
+            profile == VAProfileHEVCMain ||
+            profile == VAProfileHEVCMain10)
             rc_attribs |= VA_RC_VBR;
 
+        if (profile == VAProfileVP9Profile0)
+            rc_attribs = i965->codec_info->vp9_brc_mode;
+
         if (profile == VAProfileH264ConstrainedBaseline ||
             profile == VAProfileH264Main ||
             profile == VAProfileH264High ||
@@ -988,6 +1001,9 @@ i965_get_rc_attributes(VADriverContextP ctx, VAProfile profile, VAEntrypoint ent
             profile == VAProfileH264StereoHigh)
             rc_attribs = i965->codec_info->lp_h264_brc_mode;
 
+        else if (profile == VAProfileVP9Profile0)
+            rc_attribs = i965->codec_info->lp_vp9_brc_mode;
+
     } else if (entrypoint == VAEntrypointFEI) {
 
         if (profile == VAProfileH264ConstrainedBaseline ||
@@ -995,6 +1011,9 @@ i965_get_rc_attributes(VADriverContextP ctx, VAProfile profile, VAEntrypoint ent
             profile == VAProfileH264High)
             rc_attribs = VA_RC_CQP;
 
+    } else if (entrypoint == VAEntrypointEncPicture) {
+        if (profile == VAProfileJPEGBaseline)
+            rc_attribs = VA_RC_CQP;
     }
 
     return rc_attribs;
@@ -1010,10 +1029,6 @@ i965_get_enc_packed_attributes(VADriverContextP ctx, VAProfile profile, VAEntryp
         entrypoint == VAEntrypointFEI) {
 
         switch (profile) {
-        case VAProfileVP8Version0_3:
-            enc_packed_attribs = VA_ENC_PACKED_HEADER_NONE;
-            break;
-
         case VAProfileMPEG2Simple:
         case VAProfileMPEG2Main:
             enc_packed_attribs = VA_ENC_PACKED_HEADER_SEQUENCE | VA_ENC_PACKED_HEADER_PICTURE | VA_ENC_PACKED_HEADER_MISC;
@@ -1129,6 +1144,11 @@ i965_GetConfigAttributes(VADriverContextP ctx,
                 } else if (profile == VAProfileHEVCMain ||
                            profile == VAProfileHEVCMain10)
                     attrib_list[i].value = ENCODER_QUALITY_RANGE_HEVC;
+                else if (profile == VAProfileVP9Profile0 &&
+                         entrypoint == VAEntrypointEncSliceLP) {
+                    attrib_list[i].value = ENCODER_QUALITY_RANGE_VP9;
+                }
+
                 break;
             } else if (entrypoint == VAEntrypointStats)
                 attrib_list[i].value = VA_ATTRIB_NOT_SUPPORTED;
@@ -1259,13 +1279,16 @@ i965_GetConfigAttributes(VADriverContextP ctx,
             break;
 
         case VAConfigAttribFEIFunctionType:
-            /* Supporing all possible modes of FEI */
-            attrib_list[i].value = VA_FEI_FUNCTION_ENC |
-                                   VA_FEI_FUNCTION_PAK | VA_FEI_FUNCTION_ENC_PAK;
+            if (entrypoint == VAEntrypointFEI) {
+                /* Supporting all possible modes of FEI */
+                attrib_list[i].value = VA_FEI_FUNCTION_ENC |
+                                       VA_FEI_FUNCTION_PAK | VA_FEI_FUNCTION_ENC_PAK;
+            }
             break;
 
         case VAConfigAttribFEIMVPredictors:
-            attrib_list[i].value = 4;
+            if (entrypoint == VAEntrypointFEI)
+                attrib_list[i].value = 4;
             break;
 
         case VAConfigAttribStats:
@@ -1412,9 +1435,21 @@ i965_CreateConfig(VADriverContextP ctx,
         if (attrib_found) {
             uint32_t enc_packed_attribs = i965_get_enc_packed_attributes(ctx, profile, entrypoint);
 
-            if (((enc_packed_attribs == VA_ENC_PACKED_HEADER_NONE) && attrib_found->value) ||
-                ((enc_packed_attribs != VA_ENC_PACKED_HEADER_NONE) && !(attrib_found->value & enc_packed_attribs)))
+            if (enc_packed_attribs == VA_ATTRIB_NOT_SUPPORTED) {
+                i965_log_info(ctx, "vaCreateConfig: invalid EncPackedHeaders attribute %#x: "
+                              "packed headers are not supported.\n", attrib_found->value);
                 vaStatus = VA_STATUS_ERROR_INVALID_VALUE;
+            } else if (attrib_found->value == 0) {
+                i965_log_info(ctx, "vaCreateConfig: setting the EncPackedHeaders attribute to zero to "
+                              "indicate that no packed headers will be used is deprecated.\n");
+            } else {
+                if (attrib_found->value & ~enc_packed_attribs) {
+                    i965_log_info(ctx, "vaCreateConfig: invalid EncPackedHeaders attribute %#x: "
+                                  "some packed headers are not supported (supported set %#x).\n",
+                                  attrib_found->value, enc_packed_attribs);
+                    vaStatus = VA_STATUS_ERROR_INVALID_VALUE;
+                }
+            }
         }
     }
 
@@ -6056,6 +6091,8 @@ i965_QuerySurfaceAttributes(VADriverContextP ctx,
             attribs[i].value.value.i = VA_FOURCC_NV12;
             i++;
 
+            break;
+
         case VAProfileNone:
             attribs[i].type = VASurfaceAttribPixelFormat;
             attribs[i].value.type = VAGenericValueTypeInteger;
@@ -6803,8 +6840,8 @@ i965_ExportSurfaceHandle(VADriverContextP ctx, VASurfaceID surface_id,
     desc = descriptor;
 
     desc->fourcc = obj_surface->fourcc;
-    desc->width  = obj_surface->width;
-    desc->height = obj_surface->height;
+    desc->width  = obj_surface->orig_width;
+    desc->height = obj_surface->orig_height;
 
     desc->num_objects     = 1;
     desc->objects[0].fd   = fd;
@@ -7327,13 +7364,13 @@ ensure_vendor_string(struct i965_driver_data *i965, const char *chipset)
     if (INTEL_DRIVER_PRE_VERSION > 0) {
         ret = snprintf(&i965->va_vendor[len], sizeof(i965->va_vendor) - len,
                        ".pre%d", INTEL_DRIVER_PRE_VERSION);
-        if (ret < 0 || ret >= sizeof(i965->va_vendor))
+        if (ret < 0 || ret >= (sizeof(i965->va_vendor) - len))
             goto error;
         len += ret;
 
         ret = snprintf(&i965->va_vendor[len], sizeof(i965->va_vendor) - len,
                        " (%s)", INTEL_DRIVER_GIT_VERSION);
-        if (ret < 0 || ret >= sizeof(i965->va_vendor))
+        if (ret < 0 || ret >= (sizeof(i965->va_vendor) - len))
             goto error;
         len += ret;
     }