summaryrefslogtreecommitdiffstats
path: root/filters
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2024-01-21 20:37:47 -0600
committerDudemanguy <random342@airmail.cc>2024-02-07 14:50:09 +0000
commit8dbbc2ad82d6ebfa986db4726e2e5006b7cb0a9d (patch)
treec9dd1bfe83ed3141275e7bf560214200e0322305 /filters
parent9ce2bafbe9a49afe65eb86b46625f12dcb1b3110 (diff)
downloadmpv-8dbbc2ad82d6ebfa986db4726e2e5006b7cb0a9d.tar.bz2
mpv-8dbbc2ad82d6ebfa986db4726e2e5006b7cb0a9d.tar.xz
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.
Diffstat (limited to 'filters')
-rw-r--r--filters/f_auto_filters.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/filters/f_auto_filters.c b/filters/f_auto_filters.c
index 3cf85d2f32..fca8894b1a 100644
--- a/filters/f_auto_filters.c
+++ b/filters/f_auto_filters.c
@@ -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;
}