| 2094 | } |
| 2095 | |
| 2096 | static av_cold int vaapi_encode_create_recon_frames(AVCodecContext *avctx) |
| 2097 | { |
| 2098 | FFHWBaseEncodeContext *base_ctx = avctx->priv_data; |
| 2099 | VAAPIEncodeContext *ctx = avctx->priv_data; |
| 2100 | AVVAAPIHWConfig *hwconfig = NULL; |
| 2101 | enum AVPixelFormat recon_format; |
| 2102 | int err; |
| 2103 | |
| 2104 | hwconfig = av_hwdevice_hwconfig_alloc(base_ctx->device_ref); |
| 2105 | if (!hwconfig) { |
| 2106 | err = AVERROR(ENOMEM); |
| 2107 | goto fail; |
| 2108 | } |
| 2109 | hwconfig->config_id = ctx->va_config; |
| 2110 | |
| 2111 | err = ff_hw_base_get_recon_format(base_ctx, (const void*)hwconfig, &recon_format); |
| 2112 | if (err < 0) |
| 2113 | goto fail; |
| 2114 | |
| 2115 | base_ctx->recon_frames_ref = av_hwframe_ctx_alloc(base_ctx->device_ref); |
| 2116 | if (!base_ctx->recon_frames_ref) { |
| 2117 | err = AVERROR(ENOMEM); |
| 2118 | goto fail; |
| 2119 | } |
| 2120 | base_ctx->recon_frames = (AVHWFramesContext*)base_ctx->recon_frames_ref->data; |
| 2121 | |
| 2122 | base_ctx->recon_frames->format = AV_PIX_FMT_VAAPI; |
| 2123 | base_ctx->recon_frames->sw_format = recon_format; |
| 2124 | base_ctx->recon_frames->width = base_ctx->surface_width; |
| 2125 | base_ctx->recon_frames->height = base_ctx->surface_height; |
| 2126 | |
| 2127 | err = av_hwframe_ctx_init(base_ctx->recon_frames_ref); |
| 2128 | if (err < 0) { |
| 2129 | av_log(avctx, AV_LOG_ERROR, "Failed to initialise reconstructed " |
| 2130 | "frame context: %d.\n", err); |
| 2131 | goto fail; |
| 2132 | } |
| 2133 | |
| 2134 | err = 0; |
| 2135 | fail: |
| 2136 | av_freep(&hwconfig); |
| 2137 | return err; |
| 2138 | } |
| 2139 | |
| 2140 | static const FFHWEncodePictureOperation vaapi_op = { |
| 2141 | .priv_size = sizeof(VAAPIEncodePicture), |
no test coverage detected