summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-12-19 17:55:14 +0100
committerwm4 <wm4@nowhere>2015-12-19 18:35:58 +0100
commit1f7c099dc0feb9a160d9018ad6ad068e0295341a (patch)
treefb46a991dc1cb41136d4ffab0f08f6308c9abcd6 /video
parent78bfee53dd32bdc70af9294b11a04722a42b10c2 (diff)
downloadmpv-1f7c099dc0feb9a160d9018ad6ad068e0295341a.tar.bz2
mpv-1f7c099dc0feb9a160d9018ad6ad068e0295341a.tar.xz
vf: remove old config() callback
Diffstat (limited to 'video')
-rw-r--r--video/filter/vf.c22
-rw-r--r--video/filter/vf.h9
-rw-r--r--video/filter/vf_crop.c21
-rw-r--r--video/filter/vf_dlopen.c49
-rw-r--r--video/filter/vf_dsize.c13
-rw-r--r--video/filter/vf_expand.c21
-rw-r--r--video/filter/vf_lavfi.c1
-rw-r--r--video/filter/vf_sub.c17
-rw-r--r--video/filter/vf_vapoursynth.c31
9 files changed, 88 insertions, 96 deletions
diff --git a/video/filter/vf.c b/video/filter/vf.c
index 0898b62d17..c5d11ef222 100644
--- a/video/filter/vf.c
+++ b/video/filter/vf.c
@@ -494,19 +494,6 @@ void vf_seek_reset(struct vf_chain *c)
vf_chain_forget_frames(c);
}
-int vf_next_config(struct vf_instance *vf,
- int width, int height, int d_width, int d_height,
- unsigned int voflags, unsigned int outfmt)
-{
- vf->fmt_out = vf->fmt_in;
- vf->fmt_out.imgfmt = outfmt;
- vf->fmt_out.w = width;
- vf->fmt_out.h = height;
- vf->fmt_out.d_w = d_width;
- vf->fmt_out.d_h = d_height;
- return 1;
-}
-
int vf_next_query_format(struct vf_instance *vf, unsigned int fmt)
{
return fmt >= IMGFMT_START && fmt < IMGFMT_END
@@ -581,14 +568,9 @@ static int vf_reconfig_wrapper(struct vf_instance *vf,
if (!mp_image_params_valid(&vf->fmt_in))
return -2;
- int r;
- if (vf->reconfig) {
+ int r = 0;
+ if (vf->reconfig)
r = vf->reconfig(vf, &vf->fmt_in, &vf->fmt_out);
- } else if (vf->config) {
- r = vf->config(vf, p->w, p->h, p->d_w, p->d_h, 0, p->imgfmt) ? 0 : -1;
- } else {
- r = 0;
- }
if (!mp_image_params_equal(&vf->fmt_in, p))
r = -2;
diff --git a/video/filter/vf.h b/video/filter/vf.h
index 62734c99cf..2bca682fbc 100644
--- a/video/filter/vf.h
+++ b/video/filter/vf.h
@@ -51,11 +51,6 @@ typedef struct vf_instance {
int (*reconfig)(struct vf_instance *vf, struct mp_image_params *in,
struct mp_image_params *out);
- // Legacy variant, use reconfig instead.
- int (*config)(struct vf_instance *vf,
- int width, int height, int d_width, int d_height,
- unsigned int flags, unsigned int outfmt);
-
int (*control)(struct vf_instance *vf, int request, void *data);
int (*query_format)(struct vf_instance *vf, unsigned int fmt);
@@ -177,12 +172,8 @@ bool vf_make_out_image_writeable(struct vf_instance *vf, struct mp_image *img);
void vf_add_output_frame(struct vf_instance *vf, struct mp_image *img);
// default wrappers:
-int vf_next_config(struct vf_instance *vf,
- int width, int height, int d_width, int d_height,
- unsigned int flags, unsigned int outfmt);
int vf_next_query_format(struct vf_instance *vf, unsigned int fmt);
-
// Helpers
void vf_rescale_dsize(int *d_width, int *d_height, int old_w, int old_h,
diff --git a/video/filter/vf_crop.c b/video/filter/vf_crop.c
index 02787b8f22..79e915fd4a 100644
--- a/video/filter/vf_crop.c
+++ b/video/filter/vf_crop.c
@@ -39,10 +39,11 @@ static const struct vf_priv_s {
//===========================================================================//
-static int config(struct vf_instance *vf,
- int width, int height, int d_width, int d_height,
- unsigned int flags, unsigned int outfmt)
+static int reconfig(struct vf_instance *vf, struct mp_image_params *in,
+ struct mp_image_params *out)
{
+ int width = in->w, height = in->h, d_width = in->d_w, d_height = in->d_h;
+
// calculate the missing parameters:
if(vf->priv->crop_w<=0 || vf->priv->crop_w>width) vf->priv->crop_w=width;
if(vf->priv->crop_h<=0 || vf->priv->crop_h>height) vf->priv->crop_h=height;
@@ -50,7 +51,7 @@ static int config(struct vf_instance *vf,
if(vf->priv->crop_y<0) vf->priv->crop_y=(height-vf->priv->crop_h)/2;
// rounding:
- struct mp_imgfmt_desc fmt = mp_imgfmt_get_desc(outfmt);
+ struct mp_imgfmt_desc fmt = mp_imgfmt_get_desc(in->imgfmt);
vf->priv->crop_x = MP_ALIGN_DOWN(vf->priv->crop_x, fmt.align_x);
vf->priv->crop_y = MP_ALIGN_DOWN(vf->priv->crop_y, fmt.align_y);
@@ -59,11 +60,17 @@ static int config(struct vf_instance *vf,
if(vf->priv->crop_w+vf->priv->crop_x>width ||
vf->priv->crop_h+vf->priv->crop_y>height){
MP_WARN(vf, "Bad position/width/height - cropped area outside of the original!\n");
- return 0;
+ return -1;
}
+
vf_rescale_dsize(&d_width, &d_height, width, height,
vf->priv->crop_w, vf->priv->crop_h);
- return vf_next_config(vf,vf->priv->crop_w,vf->priv->crop_h,d_width,d_height,flags,outfmt);
+ *out = *in;
+ out->w = vf->priv->crop_w;
+ out->h = vf->priv->crop_h;
+ out->d_w = d_width;
+ out->d_h = d_height;
+ return 0;
}
static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
@@ -82,7 +89,7 @@ static int query_format(struct vf_instance *vf, unsigned int fmt)
}
static int vf_open(vf_instance_t *vf){
- vf->config=config;
+ vf->reconfig=reconfig;
vf->filter=filter;
vf->query_format=query_format;
return 1;
diff --git a/video/filter/vf_dlopen.c b/video/filter/vf_dlopen.c
index 3ba4a0dfec..7cf04ca428 100644
--- a/video/filter/vf_dlopen.c
+++ b/video/filter/vf_dlopen.c
@@ -90,29 +90,28 @@ static void set_imgprop(struct vf_dlopen_picdata *out, const mp_image_t *mpi)
}
}
-static int config(struct vf_instance *vf,
- int width, int height, int d_width, int d_height,
- unsigned int flags, unsigned int fmt)
+static int reconfig(struct vf_instance *vf, struct mp_image_params *in,
+ struct mp_image_params *out)
{
- vf->priv->filter.in_width = width;
- vf->priv->filter.in_height = height;
- vf->priv->filter.in_d_width = d_width;
- vf->priv->filter.in_d_height = d_height;
- vf->priv->filter.in_fmt = talloc_strdup(vf, mp_imgfmt_to_name(fmt));
- vf->priv->filter.out_width = width;
- vf->priv->filter.out_height = height;
- vf->priv->filter.out_d_width = d_width;
- vf->priv->filter.out_d_height = d_height;
+ vf->priv->filter.in_width = in->w;
+ vf->priv->filter.in_height = in->h;
+ vf->priv->filter.in_d_width = in->d_w;
+ vf->priv->filter.in_d_height = in->d_h;
+ vf->priv->filter.in_fmt = talloc_strdup(vf, mp_imgfmt_to_name(in->imgfmt));
+ vf->priv->filter.out_width = vf->priv->filter.in_width;
+ vf->priv->filter.out_height = vf->priv->filter.in_height;
+ vf->priv->filter.out_d_width = vf->priv->filter.in_d_width;
+ vf->priv->filter.out_d_height = vf->priv->filter.in_d_height;
vf->priv->filter.out_fmt = NULL;
vf->priv->filter.out_cnt = 1;
if (!vf->priv->filter.in_fmt) {
MP_ERR(vf, "invalid input/output format\n");
- return 0;
+ return -1;
}
if (vf->priv->filter.config && vf->priv->filter.config(&vf->priv->filter) < 0) {
MP_ERR(vf, "filter config failed\n");
- return 0;
+ return -1;
}
// copy away stuff to sanity island
@@ -137,18 +136,18 @@ static int config(struct vf_instance *vf,
}
}
} else
- vf->priv->outfmt = fmt;
+ vf->priv->outfmt = in->imgfmt;
vf->priv->filter.out_fmt =
talloc_strdup(vf, mp_imgfmt_to_name(vf->priv->outfmt));
}
if (!vf->priv->outfmt) {
MP_ERR(vf, "filter config wants an unsupported output format\n");
- return 0;
+ return -1;
}
if (!vf->priv->out_cnt || vf->priv->out_cnt > FILTER_MAX_OUTCNT) {
MP_ERR(vf, "filter config wants to yield zero or too many output frames\n");
- return 0;
+ return -1;
}
for (int i = 0; i < vf->priv->out_cnt; ++i) {
@@ -157,16 +156,18 @@ static int config(struct vf_instance *vf,
mp_image_alloc(vf->priv->outfmt,
vf->priv->out_width, vf->priv->out_height);
if (!vf->priv->outpic[i])
- return 0; // OOM
+ return -1; // OOM
talloc_steal(vf, vf->priv->outpic[i]);
set_imgprop(&vf->priv->filter.outpic[i], vf->priv->outpic[i]);
}
- return vf_next_config(vf, vf->priv->out_width,
- vf->priv->out_height,
- vf->priv->filter.out_d_width,
- vf->priv->filter.out_d_height,
- flags, vf->priv->outfmt);
+ *out = *in;
+ out->w = vf->priv->out_width;
+ out->h = vf->priv->out_height;
+ out->d_w = vf->priv->filter.out_d_width;
+ out->d_h = vf->priv->filter.out_d_height;
+ out->imgfmt = vf->priv->outfmt;
+ return 0;
}
static void uninit(struct vf_instance *vf)
@@ -307,7 +308,7 @@ static int vf_open(vf_instance_t *vf)
vf->filter_ext = filter;
vf->query_format = query_format;
- vf->config = config;
+ vf->reconfig = reconfig;
vf->uninit = uninit;
return 1;
diff --git a/video/filter/vf_dsize.c b/video/filter/vf_dsize.c
index 476ec27204..eafcaf3472 100644
--- a/video/filter/vf_dsize.c
+++ b/video/filter/vf_dsize.c
@@ -36,10 +36,10 @@ struct vf_priv_s {
float aspect;
};
-static int config(struct vf_instance *vf,
- int width, int height, int d_width, int d_height,
- unsigned int flags, unsigned int outfmt)
+static int reconfig(struct vf_instance *vf, struct mp_image_params *in,
+ struct mp_image_params *out)
{
+ int width = in->w, height = in->h, d_width = in->d_w, d_height = in->d_h;
int w = vf->priv->w;
int h = vf->priv->h;
if (vf->priv->aspect < 0.001) { // did the user input aspect or w,h params
@@ -74,12 +74,15 @@ static int config(struct vf_instance *vf,
d_width = width;
}
}
- return vf_next_config(vf, width, height, d_width, d_height, flags, outfmt);
+ *out = *in;
+ out->d_w = d_width;
+ out->d_h = d_height;
+ return 0;
}
static int vf_open(vf_instance_t *vf)
{
- vf->config = config;
+ vf->reconfig = reconfig;
return 1;
}
diff --git a/video/filter/vf_expand.c b/video/filter/vf_expand.c
index 6d5b694613..69574efff3 100644
--- a/video/filter/vf_expand.c
+++ b/video/filter/vf_expand.c
@@ -55,10 +55,11 @@ static struct vf_priv_s {
//===========================================================================//
-static int config(struct vf_instance *vf,
- int width, int height, int d_width, int d_height,
- unsigned int flags, unsigned int outfmt)
+static int reconfig(struct vf_instance *vf, struct mp_image_params *in,
+ struct mp_image_params *out)
{
+ int width = in->w, height = in->h;
+
vf->priv->exp_x = vf->priv->cfg_exp_x;
vf->priv->exp_y = vf->priv->cfg_exp_y;
vf->priv->exp_w = vf->priv->cfg_exp_w;
@@ -71,7 +72,7 @@ static int config(struct vf_instance *vf,
else if( vf->priv->exp_h<height ) vf->priv->exp_h=height;
if (vf->priv->aspect) {
float adjusted_aspect = vf->priv->aspect;
- adjusted_aspect *= ((double)width/height) / ((double)d_width/d_height);
+ adjusted_aspect *= ((double)width/height) / ((double)in->d_w/in->d_h);
if (vf->priv->exp_h < vf->priv->exp_w / adjusted_aspect) {
vf->priv->exp_h = vf->priv->exp_w / adjusted_aspect + 0.5;
} else {
@@ -86,15 +87,19 @@ static int config(struct vf_instance *vf,
if(vf->priv->exp_x<0 || vf->priv->exp_x+width>vf->priv->exp_w) vf->priv->exp_x=(vf->priv->exp_w-width)/2;
if(vf->priv->exp_y<0 || vf->priv->exp_y+height>vf->priv->exp_h) vf->priv->exp_y=(vf->priv->exp_h-height)/2;
- struct mp_imgfmt_desc fmt = mp_imgfmt_get_desc(outfmt);
+ struct mp_imgfmt_desc fmt = mp_imgfmt_get_desc(in->imgfmt);
vf->priv->exp_x = MP_ALIGN_DOWN(vf->priv->exp_x, fmt.align_x);
vf->priv->exp_y = MP_ALIGN_DOWN(vf->priv->exp_y, fmt.align_y);
- vf_rescale_dsize(&d_width, &d_height, width, height,
+ *out = *in;
+ out->w = vf->priv->exp_w;
+ out->h = vf->priv->exp_h;
+
+ vf_rescale_dsize(&out->d_w, &out->d_h, width, height,
vf->priv->exp_w, vf->priv->exp_h);
- return vf_next_config(vf,vf->priv->exp_w,vf->priv->exp_h,d_width,d_height,flags,outfmt);
+ return 0;
}
static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
@@ -140,7 +145,7 @@ static int query_format(struct vf_instance *vf, unsigned int fmt)
}
static int vf_open(vf_instance_t *vf){
- vf->config=config;
+ vf->reconfig=reconfig;
vf->query_format=query_format;
vf->filter=filter;
return 1;
diff --git a/video/filter/vf_lavfi.c b/video/filter/vf_lavfi.c
index f413cf2882..a64738d355 100644
--- a/video/filter/vf_lavfi.c
+++ b/video/filter/vf_lavfi.c
@@ -383,7 +383,6 @@ static void uninit(struct vf_instance *vf)
static int vf_open(vf_instance_t *vf)
{
vf->reconfig = reconfig;
- vf->config = NULL;
vf->filter_ext = filter_ext;
vf->filter_out = filter_out;
vf->filter = NULL;
diff --git a/video/filter/vf_sub.c b/video/filter/vf_sub.c
index 20069ee1b1..f44c4c0a67 100644
--- a/video/filter/vf_sub.c
+++ b/video/filter/vf_sub.c
@@ -49,10 +49,11 @@ struct vf_priv_s {
struct mp_osd_res dim;
};
-static int config(struct vf_instance *vf,
- int width, int height, int d_width, int d_height,
- unsigned int flags, unsigned int outfmt)
+static int reconfig(struct vf_instance *vf, struct mp_image_params *in,
+ struct mp_image_params *out)
{
+ int width = in->w, height = in->h, d_width = in->d_w, d_height = in->d_h;
+
vf->priv->outh = height + vf->priv->opt_top_margin +
vf->priv->opt_bottom_margin;
vf->priv->outw = width;
@@ -71,8 +72,12 @@ static int config(struct vf_instance *vf,
.display_par = sar / dar,
};
- return vf_next_config(vf, vf->priv->outw, vf->priv->outh, d_width,
- d_height, flags, outfmt);
+ *out = *in;
+ out->w = vf->priv->outw;
+ out->h = vf->priv->outh;
+ out->d_w = d_width;
+ out->d_h = d_height;
+ return 0;
}
static void prepare_image(struct vf_instance *vf, struct mp_image *dmpi,
@@ -130,7 +135,7 @@ static int control(vf_instance_t *vf, int request, void *data)
static int vf_open(vf_instance_t *vf)
{
- vf->config = config;
+ vf->reconfig = reconfig;
vf->query_format = query_format;
vf->control = control;
vf->filter = filter;
diff --git a/video/filter/vf_vapoursynth.c b/video/filter/vf_vapoursynth.c
index 56cbf8ebe5..68a43d8210 100644
--- a/video/filter/vf_vapoursynth.c
+++ b/video/filter/vf_vapoursynth.c
@@ -648,41 +648,40 @@ error:
return res;
}
-static int config(struct vf_instance *vf, int width, int height,
- int d_width, int d_height, unsigned int flags,
- unsigned int fmt)
+static int reconfig(struct vf_instance *vf, struct mp_image_params *in,
+ struct mp_image_params *out)
{
+ int width = in->w, height = in->h, d_width = in->d_w, d_height = in->d_h;
+
struct vf_priv_s *p = vf->priv;
- p->fmt_in = (struct mp_image_params){
- .imgfmt = fmt,
- .w = width,
- .h = height,
- .d_w = d_width,
- .d_h = d_height,
- };
+ p->fmt_in = *in;
if (reinit_vs(vf) < 0)
- return 0;
+ return -1;
const VSVideoInfo *vi = p->vsapi->getVideoInfo(p->out_node);
fmt = mp_from_vs(vi->format->id);
if (!fmt) {
MP_FATAL(vf, "Unsupported output format.\n");
destroy_vs(vf);
- return 0;
+ return -1;
}
- struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(fmt);
+ struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(in->imgfmt);
if (width % desc.align_x || height % desc.align_y) {
MP_FATAL(vf, "VapourSynth does not allow unaligned/cropped video sizes.\n");
destroy_vs(vf);
- return 0;
+ return -1;
}
vf_rescale_dsize(&d_width, &d_height, width, height, vi->width, vi->height);
-
- return vf_next_config(vf, vi->width, vi->height, d_width, d_height, flags, fmt);
+ *out = *in;
+ out->w = vi->width;
+ out->h = vi->height;
+ out->d_w = d_width;
+ out->d_h = d_height;
+ return 0;
}
static int query_format(struct vf_instance *vf, unsigned int fmt)