MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / vaapi_encode_init_quality

Function vaapi_encode_init_quality

libavcodec/vaapi_encode.c:1975–2020  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1973}
1974
1975static av_cold int vaapi_encode_init_quality(AVCodecContext *avctx)
1976{
1977#if VA_CHECK_VERSION(0, 36, 0)
1978 VAAPIEncodeContext *ctx = avctx->priv_data;
1979 VAStatus vas;
1980 VAConfigAttrib attr = { VAConfigAttribEncQualityRange };
1981 int quality = avctx->compression_level;
1982
1983 vas = vaGetConfigAttributes(ctx->hwctx->display,
1984 ctx->va_profile,
1985 ctx->va_entrypoint,
1986 &attr, 1);
1987 if (vas != VA_STATUS_SUCCESS) {
1988 av_log(avctx, AV_LOG_ERROR, "Failed to query quality "
1989 "config attribute: %d (%s).\n", vas, vaErrorStr(vas));
1990 return AVERROR_EXTERNAL;
1991 }
1992
1993 if (attr.value == VA_ATTRIB_NOT_SUPPORTED) {
1994 if (quality != 0) {
1995 av_log(avctx, AV_LOG_WARNING, "Quality attribute is not "
1996 "supported: will use default quality level.\n");
1997 }
1998 } else {
1999 if (quality > attr.value) {
2000 av_log(avctx, AV_LOG_WARNING, "Invalid quality level: "
2001 "valid range is 0-%d, using %d.\n",
2002 attr.value, attr.value);
2003 quality = attr.value;
2004 }
2005
2006 ctx->quality_params = (VAEncMiscParameterBufferQualityLevel) {
2007 .quality_level = quality,
2008 };
2009 vaapi_encode_add_global_param(avctx,
2010 VAEncMiscParameterTypeQualityLevel,
2011 &ctx->quality_params,
2012 sizeof(ctx->quality_params));
2013 }
2014#else
2015 av_log(avctx, AV_LOG_WARNING, "The encode quality option is "
2016 "not supported with this VAAPI version.\n");
2017#endif
2018
2019 return 0;
2020}
2021
2022static av_cold int vaapi_encode_init_roi(AVCodecContext *avctx)
2023{

Callers 1

ff_vaapi_encode_initFunction · 0.85

Calls 2

av_logFunction · 0.85

Tested by

no test coverage detected