From e5bceb061b50fe405caa0851f2d309e6801e82f7 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 23 Jan 2015 13:25:24 +0100 Subject: vf_vavpp: add more deinterlacing algorithms These are untested due to lack of hardware. From what I've heard, the drivers are pretty buggy, so it's not clear how well this works, if at all. --- DOCS/man/vf.rst | 4 ++++ video/filter/vf_vavpp.c | 29 ++++++++++++++++++++++------- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/DOCS/man/vf.rst b/DOCS/man/vf.rst index bc95d0e1c5..5690b28ccb 100644 --- a/DOCS/man/vf.rst +++ b/DOCS/man/vf.rst @@ -823,6 +823,10 @@ Available filters are: Show only first field (going by ``--field-dominance``). bob bob deinterlacing (default). + weave, motion-adaptive, motion-compensated + Advanced deinterlacing algorithms. Whether these actually work + depends on the GPU hardware, the GPU drivers, driver bugs, and + mpv bugs. ``vdpaupp`` VDPAU video post processing. Works with ``--vo=vdpau`` and ``--vo=opengl`` diff --git a/video/filter/vf_vavpp.c b/video/filter/vf_vavpp.c index 4e39affd41..54648e124c 100644 --- a/video/filter/vf_vavpp.c +++ b/video/filter/vf_vavpp.c @@ -71,6 +71,16 @@ static const struct vf_priv_s vf_priv_default = { .deint_type = 2, }; +// The array items must match with the "deint" suboption values. +static const int deint_algorithm[] = { + [0] = VAProcDeinterlacingNone, + [1] = VAProcDeinterlacingNone, // first-field, special-cased + [2] = VAProcDeinterlacingBob, + [3] = VAProcDeinterlacingWeave, + [4] = VAProcDeinterlacingMotionAdaptive, + [5] = VAProcDeinterlacingMotionCompensated, +}; + static inline void realloc_refs(struct surface_refs *refs, int num) { if (refs->num_allocated < num) { @@ -192,7 +202,8 @@ static int process(struct vf_instance *vf, struct mp_image *in, if (!*out1) // cannot render return 0; mp_image_copy_attributes(*out1, in); - if (field == VA_FRAME_PICTURE || p->deint_type < 2) // first-field only + // first-field only + if (field == VA_FRAME_PICTURE || (p->do_deint && p->deint_type < 2)) return 1; const double add = (in->pts - p->prev_pts)*0.5; if (p->prev_pts == MP_NOPTS_VALUE || add <= 0.0 || add > 0.5) // no pts, skip it @@ -353,15 +364,15 @@ static bool initialize(struct vf_instance *vf) buffers[i] = VA_INVALID_ID; for (int i=0; ideint_type) + if (p->deint_type < 2) continue; VAProcFilterCapDeinterlacing caps[VAProcDeinterlacingCount]; int num = va_query_filter_caps(vf, VAProcFilterDeinterlacing, caps, VAProcDeinterlacingCount); if (!num) continue; - VAProcDeinterlacingType algorithm = VAProcDeinterlacingBob; - for (int n=0; n < num; n++) { // find Bob + VAProcDeinterlacingType algorithm = deint_algorithm[p->deint_type]; + for (int n=0; n < num; n++) { // find the algorithm if (caps[n].type != algorithm) continue; VAProcFilterParameterBufferDeinterlacing param; @@ -370,13 +381,13 @@ static bool initialize(struct vf_instance *vf) buffers[VAProcFilterDeinterlacing] = va_create_filter_buffer(vf, sizeof(param), 1, ¶m); } + if (buffers[VAProcFilterDeinterlacing] == VA_INVALID_ID) + MP_WARN(vf, "Selected deinterlacing algorithm not supported.\n"); } // check other filters } p->num_buffers = 0; if (buffers[VAProcFilterDeinterlacing] != VA_INVALID_ID) p->buffers[p->num_buffers++] = buffers[VAProcFilterDeinterlacing]; - else - p->deint_type = 0; p->do_deint = !!p->deint_type; // next filters: p->buffers[p->num_buffers++] = buffers[next_filter]; return true; @@ -407,9 +418,13 @@ static int vf_open(vf_instance_t *vf) #define OPT_BASE_STRUCT struct vf_priv_s static const m_option_t vf_opts_fields[] = { OPT_CHOICE("deint", deint_type, 0, + // The values must match with deint_algorithm[]. ({"no", 0}, {"first-field", 1}, - {"bob", 2})), + {"bob", 2}, + {"weave", 3}, + {"motion-adaptive", 4}, + {"motion-compensated", 5})), {0} }; -- cgit v1.2.3