summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author1nsane000 <33362569+1nsane000@users.noreply.github.com>2024-03-05 02:20:01 +0100
committerPhilip Langdale <github.philipl@overt.org>2024-03-04 17:41:40 -0800
commit38a8e9bcba3bd31ecf5efbeee07c2169f82192d8 (patch)
treec17f5ec8f5c883c2639b12be6f63c8b5d5ea768e
parentc1029aaa820de8193e2a466039d2acccca610fd6 (diff)
downloadmpv-38a8e9bcba3bd31ecf5efbeee07c2169f82192d8.tar.bz2
mpv-38a8e9bcba3bd31ecf5efbeee07c2169f82192d8.tar.xz
options: add --deinterlace-field-parity option
Previously there was no way to specify the field order of interlaced videos when deinterlacing with inbuilt filters. Lavfi deinterlacers seemed to prefer top field order while inbuilt ones (vdpaupp, vavpp, d3d11vpp) seemed to prefer bottom field order. The default "auto" option should work exactly as before while specifying either "tff" or "bff" should force the specified field order
-rw-r--r--DOCS/interface-changes.rst1
-rw-r--r--DOCS/man/options.rst11
-rw-r--r--options/options.c8
-rw-r--r--options/options.h1
-rw-r--r--video/filter/refqueue.h4
5 files changed, 25 insertions, 0 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index 2abf99ed93..13f8cf20ef 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -28,6 +28,7 @@ Interface changes
--- mpv 0.38.0 ---
- add `begin-vo-dragging` command
+ - add `--deinterlace-field-parity` option
- add `--volume-gain`, `--volume-gain-min`, and `--volume-gain-max` options
- add `current-gpu-context` property
- add `--secondary-sub-ass-override` option
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 178b739c8d..6a09cf3884 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -1676,6 +1676,17 @@ Video
inserted deinterlacing filters, and that this will make video look worse if
it's not actually interlaced.
+``--deinterlace-field-parity=<tff|bff|auto>``
+ Specify the field parity/order when deinterlacing(default: auto)
+ Each frame of an interlaced video is divided into two fields, which are
+ then separately transmitted. Top field represents even lines while bottom
+ field represents odd lines. When deinterlacing the deinterlacer needs to
+ know the correct temporal order of the fields else the video will appear
+ jittery.
+
+ ``auto`` will automatically try to detect the field order of the video,
+ ``tff`` forces top field first while ``bff`` forces bottom field first.
+
``--frames=<number>``
Play/convert only first ``<number>`` video frames, then quit.
diff --git a/options/options.c b/options/options.c
index 3675d5734d..796a6c668b 100644
--- a/options/options.c
+++ b/options/options.c
@@ -42,6 +42,7 @@
#include "input/event.h"
#include "stream/stream.h"
#include "video/csputils.h"
+#include "video/filter/refqueue.h"
#include "video/hwdec.h"
#include "video/image_writer.h"
#include "sub/osd.h"
@@ -440,9 +441,16 @@ const struct m_sub_options filter_conf = {
.opts = (const struct m_option[]){
{"deinterlace", OPT_CHOICE(deinterlace,
{"no", 0}, {"yes", 1}, {"auto", -1})},
+ {"deinterlace-field-parity", OPT_CHOICE(field_parity,
+ {"tff", MP_FIELD_PARITY_TFF},
+ {"bff", MP_FIELD_PARITY_BFF},
+ {"auto", MP_FIELD_PARITY_AUTO})},
{0}
},
.size = sizeof(OPT_BASE_STRUCT),
+ .defaults = &(const struct filter_opts){
+ .field_parity = MP_FIELD_PARITY_AUTO,
+ },
.change_flags = UPDATE_IMGPAR,
};
diff --git a/options/options.h b/options/options.h
index 9dce3f609c..1b7c3e3583 100644
--- a/options/options.h
+++ b/options/options.h
@@ -399,6 +399,7 @@ struct dvd_opts {
struct filter_opts {
int deinterlace;
+ int field_parity;
};
extern const struct m_sub_options vo_sub_opts;
diff --git a/video/filter/refqueue.h b/video/filter/refqueue.h
index 0a8ace0031..9d47ee87fb 100644
--- a/video/filter/refqueue.h
+++ b/video/filter/refqueue.h
@@ -29,6 +29,10 @@ enum {
MP_MODE_INTERLACED_ONLY = (1 << 2), // only deinterlace marked frames
};
+#define MP_FIELD_PARITY_AUTO -1
+#define MP_FIELD_PARITY_TFF 0
+#define MP_FIELD_PARITY_BFF 1
+
void mp_refqueue_set_mode(struct mp_refqueue *q, int flags);
bool mp_refqueue_should_deint(struct mp_refqueue *q);
bool mp_refqueue_is_top_field(struct mp_refqueue *q);