- &ctx->output_width, &ctx->output_height)) < 0)
- goto fail;
-
- if (ctx->output_width < constraints->min_width ||
- ctx->output_height < constraints->min_height ||
- ctx->output_width > constraints->max_width ||
- ctx->output_height > constraints->max_height) {
- av_log(ctx, AV_LOG_ERROR, "Hardware does not support scaling to "
- "size %dx%d (constraints: width %d-%d height %d-%d).\n",
- ctx->output_width, ctx->output_height,
- constraints->min_width, constraints->max_width,
- constraints->min_height, constraints->max_height);
- err = AVERROR(EINVAL);
- goto fail;
- }
-
- ctx->output_frames_ref = av_hwframe_ctx_alloc(ctx->device_ref);
- if (!ctx->output_frames_ref) {
- av_log(ctx, AV_LOG_ERROR, "Failed to create HW frame context "
- "for output.\n");
- err = AVERROR(ENOMEM);
- goto fail;
- }
-
- ctx->output_frames = (AVHWFramesContext*)ctx->output_frames_ref->data;
-
- ctx->output_frames->format = AV_PIX_FMT_VAAPI;
- ctx->output_frames->sw_format = ctx->output_format;
- ctx->output_frames->width = ctx->output_width;
- ctx->output_frames->height = ctx->output_height;
-
- // The number of output frames we need is determined by what follows
- // the filter. If it's an encoder with complex frame reference
- // structures then this could be very high.
- ctx->output_frames->initial_pool_size = 10;
-
- err = av_hwframe_ctx_init(ctx->output_frames_ref);
- if (err < 0) {
- av_log(ctx, AV_LOG_ERROR, "Failed to initialise VAAPI frame "
- "context for output: %d\n", err);
- goto fail;
- }
-
- va_frames = ctx->output_frames->hwctx;
-
- av_assert0(ctx->va_context == VA_INVALID_ID);
- vas = vaCreateContext(ctx->hwctx->display, ctx->va_config,
- ctx->output_width, ctx->output_height,
- VA_PROGRESSIVE,
- va_frames->surface_ids, va_frames->nb_surfaces,
- &ctx->va_context);
- if (vas != VA_STATUS_SUCCESS) {
- av_log(ctx, AV_LOG_ERROR, "Failed to create processing pipeline "
- "context: %d (%s).\n", vas, vaErrorStr(vas));
- return AVERROR(EIO);
- }