mirror of https://github.com/mpv-player/mpv
player: add an auto option to deinterlace
Deinterlacing required that the user set it on/off themselves, but we actually have handy flags for detecting if a frame is interlaced. So it's pretty simple to make an auto option using that. Unfortunately, life is not quite that simple and there are known cases of false positives from the ffmpeg flags so we can't make auto the default value. However, it still may have some utility for some people, and the detection could potentially be improved upon later. Closes #10358.
This commit is contained in:
parent
9ce2bafbe9
commit
8dbbc2ad82
|
@ -45,6 +45,7 @@ Interface changes
|
|||
- add the command `load-config-file`
|
||||
- add the command `load-input-conf`
|
||||
- remove `--vo=rpi`, `--gpu-context=rpi`, and `--hwdec=mmal`
|
||||
- add `auto` choice to `--deinterlace`
|
||||
--- mpv 0.37.0 ---
|
||||
- `--save-position-on-quit` and its associated commands now store state files
|
||||
in %LOCALAPPDATA% instead of %APPDATA% directory by default on Windows.
|
||||
|
|
|
@ -206,7 +206,7 @@ Shift+PGUP and Shift+PGDWN
|
|||
PGUP/PGDWN without Shift.)
|
||||
|
||||
d
|
||||
Activate/deactivate deinterlacer.
|
||||
Cycle the deinterlacing filter.
|
||||
|
||||
A
|
||||
Cycle aspect ratio override.
|
||||
|
|
|
@ -1659,23 +1659,22 @@ Video
|
|||
|
||||
Works in ``--no-correct-pts`` mode only.
|
||||
|
||||
``--deinterlace=<yes|no>``
|
||||
``--deinterlace=<yes|no|auto>``
|
||||
Enable or disable interlacing (default: no).
|
||||
Interlaced video shows ugly comb-like artifacts, which are visible on
|
||||
fast movement. Enabling this typically inserts the bwdif video filter in
|
||||
order to deinterlace the video, or lets the video output apply deinterlacing
|
||||
if supported.
|
||||
|
||||
This behaves exactly like the ``deinterlace`` input property (usually
|
||||
mapped to ``d``).
|
||||
When using ``auto``, mpv will insert a deinterlacing filter if ffmpeg
|
||||
detects that the video frame is interlaced. Be aware that there can be false
|
||||
positives in certain cases, such as when files are encoded as interlaced
|
||||
despite the video not actually being so. This is why ``auto`` is not the
|
||||
default value.
|
||||
|
||||
Keep in mind that this **will** conflict with manually inserted
|
||||
deinterlacing filters, unless you take care. (Since mpv 0.27.0, even the
|
||||
hardware deinterlace filters will conflict. Also since that version,
|
||||
``--deinterlace=auto`` was removed, which used to mean that the default
|
||||
interlacing option of possibly inserted video filters was used.)
|
||||
|
||||
Note that this will make video look worse if it's not actually interlaced.
|
||||
Keep in mind that using this filter **will** conflict with any manually
|
||||
inserted deinterlacing filters, and that this will make video look worse if
|
||||
it's not actually interlaced.
|
||||
|
||||
``--frames=<number>``
|
||||
Play/convert only first ``<number>`` video frames, then quit.
|
||||
|
|
|
@ -118,7 +118,7 @@
|
|||
#Alt+0 set current-window-scale 0.5 # halve the window size
|
||||
#Alt+1 set current-window-scale 1.0 # reset the window size
|
||||
#Alt+2 set current-window-scale 2.0 # double the window size
|
||||
#d cycle deinterlace # toggle the deinterlacing filter
|
||||
#d cycle deinterlace # cycle the deinterlacing filter
|
||||
#r add sub-pos -1 # move subtitles up
|
||||
#R add sub-pos +1 # move subtitles down
|
||||
#t add sub-pos +1 # move subtitles down
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
struct deint_priv {
|
||||
struct mp_subfilter sub;
|
||||
int prev_imgfmt;
|
||||
int prev_setting;
|
||||
bool deinterlace_active;
|
||||
struct m_config_cache *opts;
|
||||
};
|
||||
|
||||
|
@ -45,15 +45,18 @@ static void deint_process(struct mp_filter *f)
|
|||
return;
|
||||
}
|
||||
|
||||
struct mp_image *img = frame.data;
|
||||
bool interlaced = img->fields & MP_IMGFIELD_INTERLACED;
|
||||
|
||||
m_config_cache_update(p->opts);
|
||||
struct filter_opts *opts = p->opts->opts;
|
||||
bool should_deinterlace = (opts->deinterlace == -1 && interlaced) ||
|
||||
opts->deinterlace == 1;
|
||||
|
||||
if (!opts->deinterlace)
|
||||
if (!should_deinterlace)
|
||||
mp_subfilter_destroy(&p->sub);
|
||||
|
||||
struct mp_image *img = frame.data;
|
||||
|
||||
if (img->imgfmt == p->prev_imgfmt && p->prev_setting == opts->deinterlace) {
|
||||
if (img->imgfmt == p->prev_imgfmt && p->deinterlace_active == should_deinterlace) {
|
||||
mp_subfilter_continue(&p->sub);
|
||||
return;
|
||||
}
|
||||
|
@ -64,8 +67,8 @@ static void deint_process(struct mp_filter *f)
|
|||
assert(!p->sub.filter);
|
||||
|
||||
p->prev_imgfmt = img->imgfmt;
|
||||
p->prev_setting = opts->deinterlace;
|
||||
if (!p->prev_setting) {
|
||||
p->deinterlace_active = should_deinterlace;
|
||||
if (!p->deinterlace_active) {
|
||||
mp_subfilter_continue(&p->sub);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -436,7 +436,8 @@ const struct m_sub_options dvd_conf = {
|
|||
|
||||
const struct m_sub_options filter_conf = {
|
||||
.opts = (const struct m_option[]){
|
||||
{"deinterlace", OPT_BOOL(deinterlace)},
|
||||
{"deinterlace", OPT_CHOICE(deinterlace,
|
||||
{"no", 0}, {"yes", 1}, {"auto", -1})},
|
||||
{0}
|
||||
},
|
||||
.size = sizeof(OPT_BASE_STRUCT),
|
||||
|
|
|
@ -397,7 +397,7 @@ struct dvd_opts {
|
|||
};
|
||||
|
||||
struct filter_opts {
|
||||
bool deinterlace;
|
||||
int deinterlace;
|
||||
};
|
||||
|
||||
extern const struct m_sub_options vo_sub_opts;
|
||||
|
|
Loading…
Reference in New Issue