]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_deinterlace_vaapi.c
avfilter: Constify all AVFilters
[ffmpeg] / libavfilter / vf_deinterlace_vaapi.c
index f7a262d0c6be1a4881e09a17ef4bcc6cf43c9328..0e645f50f249cc980299451ea90239383703f496 100644 (file)
@@ -113,6 +113,7 @@ static int deint_vaapi_build_filter_params(AVFilterContext *avctx)
             av_log(avctx, AV_LOG_ERROR, "Deinterlacing mode %d (%s) is "
                    "not supported.\n", ctx->mode,
                    deint_vaapi_mode_name(ctx->mode));
+            return AVERROR(EINVAL);
         }
     }
 
@@ -180,12 +181,11 @@ static int deint_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
     VAAPIVPPContext *vpp_ctx = avctx->priv;
     DeintVAAPIContext *ctx   = avctx->priv;
     AVFrame *output_frame    = NULL;
-    VASurfaceID input_surface, output_surface;
+    VASurfaceID input_surface;
     VASurfaceID backward_references[MAX_REFERENCES];
     VASurfaceID forward_references[MAX_REFERENCES];
     VAProcPipelineParameterBuffer params;
     VAProcFilterParameterBufferDeinterlacing *filter_params;
-    VARectangle input_region;
     VAStatus vas;
     void *filter_params_addr = NULL;
     int err, i, field, current_frame_index;
@@ -237,30 +237,14 @@ static int deint_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
             goto fail;
         }
 
-        output_surface = (VASurfaceID)(uintptr_t)output_frame->data[3];
-        av_log(avctx, AV_LOG_DEBUG, "Using surface %#x for "
-               "deinterlace output.\n", output_surface);
-
-        memset(&params, 0, sizeof(params));
-
-        input_region = (VARectangle) {
-            .x      = 0,
-            .y      = 0,
-            .width  = input_frame->width,
-            .height = input_frame->height,
-        };
-
-        params.surface = input_surface;
-        params.surface_region = &input_region;
-        params.surface_color_standard =
-            ff_vaapi_vpp_colour_standard(input_frame->colorspace);
-
-        params.output_region = NULL;
-        params.output_background_color = 0xff000000;
-        params.output_color_standard = params.surface_color_standard;
+        err = av_frame_copy_props(output_frame, input_frame);
+        if (err < 0)
+            goto fail;
 
-        params.pipeline_flags = 0;
-        params.filter_flags   = VA_FRAME_PICTURE;
+        err = ff_vaapi_vpp_init_params(avctx, &params,
+                                       input_frame, output_frame);
+        if (err < 0)
+            goto fail;
 
         if (!ctx->auto_enable || input_frame->interlaced_frame) {
             vas = vaMapBuffer(vpp_ctx->hwctx->display, vpp_ctx->filter_buffers[0],
@@ -300,11 +284,7 @@ static int deint_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
             params.num_filters = 0;
         }
 
-        err = ff_vaapi_vpp_render_picture(avctx, &params, output_surface);
-        if (err < 0)
-            goto fail;
-
-        err = av_frame_copy_props(output_frame, input_frame);
+        err = ff_vaapi_vpp_render_picture(avctx, &params, output_frame);
         if (err < 0)
             goto fail;
 
@@ -403,7 +383,7 @@ static const AVFilterPad deint_vaapi_outputs[] = {
     { NULL }
 };
 
-AVFilter ff_vf_deinterlace_vaapi = {
+const AVFilter ff_vf_deinterlace_vaapi = {
     .name           = "deinterlace_vaapi",
     .description    = NULL_IF_CONFIG_SMALL("Deinterlacing of VAAPI surfaces"),
     .priv_size      = sizeof(DeintVAAPIContext),