From 5597db7081b9420e0305c717435b18c71e72cb02 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 30 Sep 2017 16:20:37 +0200 Subject: vf_vavpp: restrict allowed sw upload formats to nv12/yuv420p We allowed any input format that was generally supported by libva, but this is probably nonsense, as the actual surface format was always fixed to nv12. We would have to check whether libva can upload a given pixel format to a nv12 surface. Or we would have to use a separate frame pool for input surfaces with the exact sw_format - but then we'd also need to check whether the vaapi VideoProc supports the surface type. Hardcode nv12 and yuv420p as input formats, which we know can be uploaded to nv12 surfaces. In theory we could get a list of supported upload formats from libavutil, but that also require allocating a dummy hw frames context just for the query. Add a comment to the upload code why we can allocate an output surface for input. In the long run, we'll probably want to use libavfilter's vaapi deinterlacer, but for now this would break at least user options. --- video/filter/vf_vavpp.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) (limited to 'video') diff --git a/video/filter/vf_vavpp.c b/video/filter/vf_vavpp.c index ee5a3386c1..4d2cc0981f 100644 --- a/video/filter/vf_vavpp.c +++ b/video/filter/vf_vavpp.c @@ -60,8 +60,6 @@ struct vf_priv_s { struct mp_vaapi_ctx *va; struct pipeline pipe; AVBufferRef *hw_pool; - int *in_formats; - int num_in_formats; struct mp_refqueue *queue; }; @@ -280,6 +278,8 @@ cleanup: static struct mp_image *upload(struct vf_instance *vf, struct mp_image *in) { + // Since we do no scaling or csp conversion, we can allocate an output + // surface for input too. struct mp_image *out = alloc_out(vf); if (!out) return NULL; @@ -391,13 +391,7 @@ static void uninit(struct vf_instance *vf) static int query_format(struct vf_instance *vf, unsigned int imgfmt) { - struct vf_priv_s *p = vf->priv; - - bool supported = false; - for (int n = 0; n < p->num_in_formats; n++) - supported |= imgfmt == p->in_formats[n]; - - if (imgfmt == IMGFMT_VAAPI || supported) + if (imgfmt == IMGFMT_VAAPI || imgfmt == IMGFMT_NV12 || imgfmt == IMGFMT_420P) return vf_next_query_format(vf, IMGFMT_VAAPI); return 0; } @@ -511,17 +505,6 @@ static int vf_open(vf_instance_t *vf) } p->display = p->va->display; - AVBufferRef *device_ref = (void *)p->va->av_device_ref; - AVHWFramesConstraints *constraints = - av_hwdevice_get_hwframe_constraints(device_ref, NULL); - const enum AVPixelFormat *fmts = constraints->valid_sw_formats; - for (int n = 0; fmts && fmts[n] != AV_PIX_FMT_NONE; n++) { - int mpfmt = pixfmt2imgfmt(fmts[n]); - if (mpfmt) - MP_TARRAY_APPEND(p, p->in_formats, p->num_in_formats, mpfmt); - } - av_hwframe_constraints_free(&constraints); - if (initialize(vf)) return true; uninit(vf); -- cgit v1.2.3