aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/vaapi_vpp.c
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2019-03-31 15:39:35 +0100
committerMark Thompson <sw@jkqxz.net>2019-06-02 17:30:41 +0100
commit6ed34a437925c5263f6c4ac7d0a9a46955055abe (patch)
tree6f4186dbe757ec69914233920370e1d3fcda50c6 /libavfilter/vaapi_vpp.c
parent963c4f85fe547ef51fafb66d7eceb3f5637d3843 (diff)
downloadffmpeg-6ed34a437925c5263f6c4ac7d0a9a46955055abe.tar.gz
lavfi/vaapi: Factorise out common code for parameter buffer setup
Also enables cropping on all VAAPI filters, inherited from the existing support in scale_vaapi.
Diffstat (limited to 'libavfilter/vaapi_vpp.c')
-rw-r--r--libavfilter/vaapi_vpp.c55
1 files changed, 52 insertions, 3 deletions
diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c
index c5bbc3b85b..647ddc0811 100644
--- a/libavfilter/vaapi_vpp.c
+++ b/libavfilter/vaapi_vpp.c
@@ -248,6 +248,52 @@ int ff_vaapi_vpp_colour_standard(enum AVColorSpace av_cs)
}
}
+int ff_vaapi_vpp_init_params(AVFilterContext *avctx,
+ VAProcPipelineParameterBuffer *params,
+ const AVFrame *input_frame,
+ AVFrame *output_frame)
+{
+ VAAPIVPPContext *ctx = avctx->priv;
+ VASurfaceID input_surface;
+
+ ctx->input_region = (VARectangle) {
+ .x = input_frame->crop_left,
+ .y = input_frame->crop_top,
+ .width = input_frame->width -
+ (input_frame->crop_left + input_frame->crop_right),
+ .height = input_frame->height -
+ (input_frame->crop_top + input_frame->crop_bottom),
+ };
+ output_frame->crop_top = 0;
+ output_frame->crop_bottom = 0;
+ output_frame->crop_left = 0;
+ output_frame->crop_right = 0;
+
+ input_surface = (VASurfaceID)(uintptr_t)input_frame->data[3],
+
+ *params = (VAProcPipelineParameterBuffer) {
+ .surface = input_surface,
+ .surface_region = &ctx->input_region,
+ .surface_color_standard =
+ ff_vaapi_vpp_colour_standard(input_frame->colorspace),
+ .output_region = NULL,
+ .output_background_color = VAAPI_VPP_BACKGROUND_BLACK,
+ .output_color_standard =
+ ff_vaapi_vpp_colour_standard(input_frame->colorspace),
+ .pipeline_flags = 0,
+ .filter_flags = VA_FRAME_PICTURE,
+
+ // Filter and reference data filled by the filter itself.
+
+#if VA_CHECK_VERSION(1, 1, 0)
+ .rotation_state = VA_ROTATION_NONE,
+ .mirror_state = VA_MIRROR_NONE,
+#endif
+ };
+
+ return 0;
+}
+
int ff_vaapi_vpp_make_param_buffers(AVFilterContext *avctx,
int type,
const void *data,
@@ -279,12 +325,15 @@ int ff_vaapi_vpp_make_param_buffers(AVFilterContext *avctx,
int ff_vaapi_vpp_render_picture(AVFilterContext *avctx,
VAProcPipelineParameterBuffer *params,
- VASurfaceID output_surface)
+ AVFrame *output_frame)
{
+ VAAPIVPPContext *ctx = avctx->priv;
+ VASurfaceID output_surface;
VABufferID params_id;
VAStatus vas;
- int err = 0;
- VAAPIVPPContext *ctx = avctx->priv;
+ int err;
+
+ output_surface = (VASurfaceID)(uintptr_t)output_frame->data[3];
vas = vaBeginPicture(ctx->hwctx->display,
ctx->va_context, output_surface);