| 871 | }; |
| 872 | |
| 873 | static av_cold int vaapi_encode_av1_init(AVCodecContext *avctx) |
| 874 | { |
| 875 | VAAPIEncodeContext *ctx = avctx->priv_data; |
| 876 | VAAPIEncodeAV1Context *priv = avctx->priv_data; |
| 877 | VAConfigAttrib attr; |
| 878 | VAStatus vas; |
| 879 | int ret; |
| 880 | |
| 881 | ctx->codec = &vaapi_encode_type_av1; |
| 882 | |
| 883 | ctx->desired_packed_headers = |
| 884 | VA_ENC_PACKED_HEADER_SEQUENCE | |
| 885 | VA_ENC_PACKED_HEADER_PICTURE | |
| 886 | VA_ENC_PACKED_HEADER_MISC; // Metadata |
| 887 | |
| 888 | if (avctx->profile == AV_PROFILE_UNKNOWN) |
| 889 | avctx->profile = priv->profile; |
| 890 | if (avctx->level == AV_LEVEL_UNKNOWN) |
| 891 | avctx->level = priv->level; |
| 892 | |
| 893 | if (avctx->level != AV_LEVEL_UNKNOWN && avctx->level & ~0x1f) { |
| 894 | av_log(avctx, AV_LOG_ERROR, "Invalid level %d\n", avctx->level); |
| 895 | return AVERROR(EINVAL); |
| 896 | } |
| 897 | |
| 898 | ret = ff_vaapi_encode_init(avctx); |
| 899 | if (ret < 0) |
| 900 | return ret; |
| 901 | |
| 902 | attr.type = VAConfigAttribEncAV1; |
| 903 | vas = vaGetConfigAttributes(ctx->hwctx->display, |
| 904 | ctx->va_profile, |
| 905 | ctx->va_entrypoint, |
| 906 | &attr, 1); |
| 907 | if (vas != VA_STATUS_SUCCESS) { |
| 908 | av_log(avctx, AV_LOG_ERROR, "Failed to query " |
| 909 | "config attribute: %d (%s).\n", vas, vaErrorStr(vas)); |
| 910 | return AVERROR_EXTERNAL; |
| 911 | } else if (attr.value == VA_ATTRIB_NOT_SUPPORTED) { |
| 912 | priv->attr.value = 0; |
| 913 | av_log(avctx, AV_LOG_WARNING, "Attribute type:%d is not " |
| 914 | "supported.\n", attr.type); |
| 915 | } else { |
| 916 | priv->attr.value = attr.value; |
| 917 | } |
| 918 | |
| 919 | attr.type = VAConfigAttribEncAV1Ext1; |
| 920 | vas = vaGetConfigAttributes(ctx->hwctx->display, |
| 921 | ctx->va_profile, |
| 922 | ctx->va_entrypoint, |
| 923 | &attr, 1); |
| 924 | if (vas != VA_STATUS_SUCCESS) { |
| 925 | av_log(avctx, AV_LOG_ERROR, "Failed to query " |
| 926 | "config attribute: %d (%s).\n", vas, vaErrorStr(vas)); |
| 927 | return AVERROR_EXTERNAL; |
| 928 | } else if (attr.value == VA_ATTRIB_NOT_SUPPORTED) { |
| 929 | priv->attr_ext1.value = 0; |
| 930 | av_log(avctx, AV_LOG_WARNING, "Attribute type:%d is not " |
nothing calls this directly
no test coverage detected