summaryrefslogtreecommitdiffstats
path: root/video/filter/vf_vavpp.c
diff options
context:
space:
mode:
Diffstat (limited to 'video/filter/vf_vavpp.c')
-rw-r--r--video/filter/vf_vavpp.c52
1 files changed, 31 insertions, 21 deletions
diff --git a/video/filter/vf_vavpp.c b/video/filter/vf_vavpp.c
index 8c41ba8734..960c74587e 100644
--- a/video/filter/vf_vavpp.c
+++ b/video/filter/vf_vavpp.c
@@ -23,7 +23,6 @@
#include <libavutil/hwcontext.h>
#include <libavutil/hwcontext_vaapi.h>
-#include "config.h"
#include "options/options.h"
#include "filters/filter.h"
#include "filters/filter_internal.h"
@@ -52,8 +51,9 @@ struct pipeline {
struct opts {
int deint_type;
- int interlaced_only;
- int reversal_bug;
+ int field_parity;
+ bool interlaced_only;
+ bool reversal_bug;
};
struct priv {
@@ -144,11 +144,13 @@ static void update_pipeline(struct mp_filter *vf)
(p->do_deint ? MP_MODE_DEINT : 0) |
(p->opts->deint_type >= 2 ? MP_MODE_OUTPUT_FIELDS : 0) |
(p->opts->interlaced_only ? MP_MODE_INTERLACED_ONLY : 0));
+ mp_refqueue_set_parity(p->queue, p->opts->field_parity);
return;
nodeint:
mp_refqueue_set_refs(p->queue, 0, 0);
mp_refqueue_set_mode(p->queue, 0);
+ mp_refqueue_set_parity(p->queue, p->opts->field_parity);
}
static struct mp_image *alloc_out(struct mp_filter *vf)
@@ -165,15 +167,15 @@ static struct mp_image *alloc_out(struct mp_filter *vf)
int src_h = hw_frames->height;
if (!mp_update_av_hw_frames_pool(&p->hw_pool, p->av_device_ref,
- IMGFMT_VAAPI, IMGFMT_NV12, src_w, src_h))
+ IMGFMT_VAAPI, IMGFMT_NV12, src_w, src_h,
+ false))
{
MP_ERR(vf, "Failed to create hw pool.\n");
return NULL;
}
AVFrame *av_frame = av_frame_alloc();
- if (!av_frame)
- abort();
+ MP_HANDLE_OOM(av_frame);
if (av_hwframe_get_buffer(p->hw_pool, av_frame, 0) < 0) {
MP_ERR(vf, "Failed to allocate frame from hw pool.\n");
av_frame_free(&av_frame);
@@ -209,7 +211,7 @@ static struct mp_image *render(struct mp_filter *vf)
mp_image_copy_attributes(img, in);
- unsigned int flags = va_get_colorspace_flag(p->params.color.space);
+ unsigned int flags = va_get_colorspace_flag(p->params.repr.sys);
if (!mp_refqueue_should_deint(p->queue)) {
flags |= VA_FRAME_PICTURE;
} else if (mp_refqueue_is_top_field(p->queue)) {
@@ -448,7 +450,11 @@ static struct mp_filter *vf_vavpp_create(struct mp_filter *parent, void *options
p->queue = mp_refqueue_alloc(f);
- p->av_device_ref = mp_filter_load_hwdec_device(f, AV_HWDEVICE_TYPE_VAAPI);
+ struct mp_hwdec_ctx *hwdec_ctx =
+ mp_filter_load_hwdec_device(f, IMGFMT_VAAPI);
+ if (!hwdec_ctx || !hwdec_ctx->av_device_ref)
+ goto error;
+ p->av_device_ref = av_buffer_ref(hwdec_ctx->av_device_ref);
if (!p->av_device_ref)
goto error;
@@ -471,17 +477,21 @@ error:
#define OPT_BASE_STRUCT struct opts
static const m_option_t vf_opts_fields[] = {
- OPT_CHOICE("deint", deint_type, 0,
- // The values >=0 must match with deint_algorithm[].
- ({"auto", -1},
- {"no", 0},
- {"first-field", 1},
- {"bob", 2},
- {"weave", 3},
- {"motion-adaptive", 4},
- {"motion-compensated", 5})),
- OPT_FLAG("interlaced-only", interlaced_only, 0),
- OPT_FLAG("reversal-bug", reversal_bug, 0),
+ {"deint", OPT_CHOICE(deint_type,
+ // The values >=0 must match with deint_algorithm[].
+ {"auto", -1},
+ {"no", 0},
+ {"first-field", 1},
+ {"bob", 2},
+ {"weave", 3},
+ {"motion-adaptive", 4},
+ {"motion-compensated", 5})},
+ {"interlaced-only", OPT_BOOL(interlaced_only)},
+ {"reversal-bug", OPT_BOOL(reversal_bug)},
+ {"parity", OPT_CHOICE(field_parity,
+ {"tff", MP_FIELD_PARITY_TFF},
+ {"bff", MP_FIELD_PARITY_BFF},
+ {"auto", MP_FIELD_PARITY_AUTO})},
{0}
};
@@ -492,8 +502,8 @@ const struct mp_user_filter_entry vf_vavpp = {
.priv_size = sizeof(OPT_BASE_STRUCT),
.priv_defaults = &(const OPT_BASE_STRUCT){
.deint_type = -1,
- .interlaced_only = 0,
- .reversal_bug = 1,
+ .reversal_bug = true,
+ .field_parity = MP_FIELD_PARITY_AUTO,
},
.options = vf_opts_fields,
},