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

Function vaapi_encode_surface_alignment

libavcodec/vaapi_encode.c:1136–1196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1134}
1135
1136static av_cold int vaapi_encode_surface_alignment(av_unused AVCodecContext *avctx)
1137{
1138#if VA_CHECK_VERSION(1, 21, 0)
1139 VAAPIEncodeContext *ctx = avctx->priv_data;
1140 VASurfaceAttrib *attr_list = NULL;
1141 unsigned int attr_count = 0;
1142 VAConfigID va_config;
1143 VAStatus vas;
1144 int err = 0;
1145
1146 vas = vaCreateConfig(ctx->hwctx->display,
1147 ctx->va_profile, ctx->va_entrypoint,
1148 NULL, 0, &va_config);
1149 if (vas != VA_STATUS_SUCCESS) {
1150 av_log(avctx, AV_LOG_ERROR, "Failed to create temp encode pipeline "
1151 "configuration: %d (%s).\n", vas, vaErrorStr(vas));
1152 return AVERROR(EIO);
1153 }
1154
1155 vas = vaQuerySurfaceAttributes(ctx->hwctx->display, va_config,
1156 0, &attr_count);
1157 if (vas != VA_STATUS_SUCCESS) {
1158 av_log(avctx, AV_LOG_ERROR, "Failed to query surface attributes: "
1159 "%d (%s).\n", vas, vaErrorStr(vas));
1160 err = AVERROR_EXTERNAL;
1161 goto fail;
1162 }
1163
1164 attr_list = av_malloc(attr_count * sizeof(*attr_list));
1165 if (!attr_list) {
1166 err = AVERROR(ENOMEM);
1167 goto fail;
1168 }
1169
1170 vas = vaQuerySurfaceAttributes(ctx->hwctx->display, va_config,
1171 attr_list, &attr_count);
1172 if (vas != VA_STATUS_SUCCESS) {
1173 av_log(avctx, AV_LOG_ERROR, "Failed to query surface attributes: "
1174 "%d (%s).\n", vas, vaErrorStr(vas));
1175 err = AVERROR_EXTERNAL;
1176 goto fail;
1177 }
1178
1179 for (unsigned int i = 0; i < attr_count; i++) {
1180 if (attr_list[i].type == VASurfaceAttribAlignmentSize) {
1181 ctx->surface_alignment_width =
1182 1 << (attr_list[i].value.value.i & 0xf);
1183 ctx->surface_alignment_height =
1184 1 << ((attr_list[i].value.value.i & 0xf0) >> 4);
1185 break;
1186 }
1187 }
1188
1189fail:
1190 av_freep(&attr_list);
1191 vaDestroyConfig(ctx->hwctx->display, va_config);
1192 return err;
1193#else

Callers 1

ff_vaapi_encode_initFunction · 0.85

Calls 3

av_logFunction · 0.85
av_freepFunction · 0.85
av_mallocFunction · 0.50

Tested by

no test coverage detected