mirror of
https://github.com/mpv-player/mpv
synced 2025-03-25 04:38:01 +00:00
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.
This commit is contained in:
parent
11d72b0999
commit
e5bceb061b
@ -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``
|
||||
|
@ -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; i<num_filters; ++i) {
|
||||
if (filters[i] == VAProcFilterDeinterlacing) {
|
||||
if (!p->deint_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}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user