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
This commit is contained in:
1nsane000 2024-03-05 02:20:01 +01:00 committed by Philip Langdale
parent c1029aaa82
commit 38a8e9bcba
5 changed files with 25 additions and 0 deletions

View File

@ -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

View File

@ -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.

View File

@ -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,
};

View File

@ -399,6 +399,7 @@ struct dvd_opts {
struct filter_opts {
int deinterlace;
int field_parity;
};
extern const struct m_sub_options vo_sub_opts;

View File

@ -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);