summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-07 19:33:11 +0100
committerwm4 <wm4@nowhere>2013-12-07 19:33:11 +0100
commit0af9ede5466fa5b02348d5cfb3182f80771a5f38 (patch)
treee314f304cac6bc675a289d5b4f6982fc713071a6 /video
parentbb6165342db0ba60fefa97afe770b393fd6cb463 (diff)
downloadmpv-0af9ede5466fa5b02348d5cfb3182f80771a5f38.tar.bz2
mpv-0af9ede5466fa5b02348d5cfb3182f80771a5f38.tar.xz
vf: remove flags from filter format status
I don't think we need these flags anymore. Simplify the code and get rid of the vf_format struct. There still is the vf_format.configured field, but this can be replaced by checking for a valid image format.
Diffstat (limited to 'video')
-rw-r--r--video/filter/vf.c42
-rw-r--r--video/filter/vf.h11
-rw-r--r--video/filter/vf_gradfun.c4
-rw-r--r--video/filter/vf_lavfi.c5
4 files changed, 25 insertions, 37 deletions
diff --git a/video/filter/vf.c b/video/filter/vf.c
index 21f89e5386..712bacbf6b 100644
--- a/video/filter/vf.c
+++ b/video/filter/vf.c
@@ -169,8 +169,8 @@ static void vf_fix_img_params(struct mp_image *img, struct mp_image_params *p)
// the last vf_config call.
struct mp_image *vf_alloc_out_image(struct vf_instance *vf)
{
- assert(vf->fmt_out.configured);
- struct mp_image_params *p = &vf->fmt_out.params;
+ struct mp_image_params *p = &vf->fmt_out;
+ assert(p->imgfmt);
struct mp_image *img = mp_image_pool_get(vf->out_pool, p->imgfmt, p->w, p->h);
vf_fix_img_params(img, p);
return img;
@@ -178,8 +178,8 @@ struct mp_image *vf_alloc_out_image(struct vf_instance *vf)
void vf_make_out_image_writeable(struct vf_instance *vf, struct mp_image *img)
{
- struct mp_image_params *p = &vf->fmt_out.params;
- assert(vf->fmt_out.configured);
+ struct mp_image_params *p = &vf->fmt_out;
+ assert(p->imgfmt);
assert(p->imgfmt == img->imgfmt);
assert(p->w == img->w && p->h == img->h);
mp_image_pool_make_writeable(vf->out_pool, img);
@@ -200,15 +200,13 @@ static struct mp_image *vf_default_filter(struct vf_instance *vf,
return mpi;
}
-static void print_fmt(int msglevel, struct vf_format *fmt)
+static void print_fmt(int msglevel, struct mp_image_params *p)
{
- if (fmt && fmt->configured) {
- struct mp_image_params *p = &fmt->params;
+ if (p && p->imgfmt) {
mp_msg(MSGT_VFILTER, msglevel, "%dx%d", p->w, p->h);
if (p->w != p->d_w || p->h != p->d_h)
mp_msg(MSGT_VFILTER, msglevel, "->%dx%d", p->d_w, p->d_h);
- mp_msg(MSGT_VFILTER, msglevel, " %s %#x", mp_imgfmt_to_name(p->imgfmt),
- fmt->flags);
+ mp_msg(MSGT_VFILTER, msglevel, " %s", mp_imgfmt_to_name(p->imgfmt));
mp_msg(MSGT_VFILTER, msglevel, " %s/%s", mp_csp_names[p->colorspace],
mp_csp_levels_names[p->colorlevels]);
} else {
@@ -323,8 +321,8 @@ void vf_add_output_frame(struct vf_instance *vf, struct mp_image *img)
{
if (img) {
// vf_vo doesn't have output config
- if (vf->fmt_out.configured)
- vf_fix_img_params(img, &vf->fmt_out.params);
+ if (vf->fmt_out.imgfmt)
+ vf_fix_img_params(img, &vf->fmt_out);
MP_TARRAY_APPEND(vf, vf->out_queued, vf->num_out_queued, img);
}
}
@@ -341,8 +339,8 @@ static struct mp_image *vf_dequeue_output_frame(struct vf_instance *vf)
static int vf_do_filter(struct vf_instance *vf, struct mp_image *img)
{
- assert(vf->fmt_in.configured);
- vf_fix_img_params(img, &vf->fmt_in.params);
+ assert(vf->fmt_in.imgfmt);
+ vf_fix_img_params(img, &vf->fmt_in);
if (vf->filter_ext) {
return vf->filter_ext(vf, img);
@@ -404,11 +402,8 @@ static int vf_reconfig_wrapper(struct vf_instance *vf, const struct mp_image_par
vf_forget_frames(vf);
mp_image_pool_clear(vf->out_pool);
- vf->fmt_in = (struct vf_format) {
- .params = *p,
- .flags = flags,
- };
- vf->fmt_out = (struct vf_format){0};
+ vf->fmt_in = *p;
+ vf->fmt_out = (struct mp_image_params){0};
int r;
if (vf->reconfig) {
@@ -419,9 +414,10 @@ static int vf_reconfig_wrapper(struct vf_instance *vf, const struct mp_image_par
r = r ? 0 : -1;
}
if (r >= 0) {
- vf->fmt_in.configured = 1;
if (vf->next)
vf->fmt_out = vf->next->fmt_in;
+ } else {
+ vf->fmt_in = (struct mp_image_params){0};
}
return r;
}
@@ -461,10 +457,10 @@ int vf_next_config(struct vf_instance *vf,
.h = height,
.d_w = d_width,
.d_h = d_height,
- .colorspace = vf->fmt_in.params.colorspace,
- .colorlevels = vf->fmt_in.params.colorlevels,
- .chroma_location = vf->fmt_in.params.chroma_location,
- .outputlevels = vf->fmt_in.params.outputlevels,
+ .colorspace = vf->fmt_in.colorspace,
+ .colorlevels = vf->fmt_in.colorlevels,
+ .chroma_location = vf->fmt_in.chroma_location,
+ .outputlevels = vf->fmt_in.outputlevels,
};
// Fix csp in case of pixel format change
mp_image_params_guess_csp(&p);
diff --git a/video/filter/vf.h b/video/filter/vf.h
index 21031de3ac..c241f1c329 100644
--- a/video/filter/vf.h
+++ b/video/filter/vf.h
@@ -41,12 +41,6 @@ typedef struct vf_info {
void (*print_help)(void);
} vf_info_t;
-struct vf_format {
- int configured;
- struct mp_image_params params;
- int flags;
-};
-
typedef struct vf_instance {
const vf_info_t *info;
@@ -76,9 +70,7 @@ typedef struct vf_instance {
char *label;
- // data:
- struct vf_format fmt_in, fmt_out;
- struct vf_instance *next;
+ struct mp_image_params fmt_in, fmt_out;
struct mp_image_pool *out_pool;
struct vf_priv_s *priv;
@@ -90,6 +82,7 @@ typedef struct vf_instance {
// Temporary
struct vf_chain *chain;
+ struct vf_instance *next;
} vf_instance_t;
// A chain of video filters
diff --git a/video/filter/vf_gradfun.c b/video/filter/vf_gradfun.c
index 39dd050002..7c9a0ecab3 100644
--- a/video/filter/vf_gradfun.c
+++ b/video/filter/vf_gradfun.c
@@ -359,8 +359,8 @@ static void uninit(struct vf_instance *vf)
static void lavfi_recreate(struct vf_instance *vf)
{
struct vf_priv_s *p = vf_lw_old_priv(vf);
- int w = vf->fmt_in.params.w;
- int h = vf->fmt_in.params.h;
+ int w = vf->fmt_in.w;
+ int h = vf->fmt_in.h;
p->radius = p->cfg_radius;
if (p->cfg_size > -1)
p->radius = (p->cfg_size / 100.0f) * sqrtf(w * w + h * h);
diff --git a/video/filter/vf_lavfi.c b/video/filter/vf_lavfi.c
index c5fe973d2b..13f7aa3867 100644
--- a/video/filter/vf_lavfi.c
+++ b/video/filter/vf_lavfi.c
@@ -306,10 +306,9 @@ static int filter_ext(struct vf_instance *vf, struct mp_image *mpi)
static void reset(vf_instance_t *vf)
{
struct vf_priv_s *p = vf->priv;
- if (p->graph) {
- struct mp_image_params *f = &vf->fmt_in.params;
+ struct mp_image_params *f = &vf->fmt_in;
+ if (p->graph && f->imgfmt)
recreate_graph(vf, f->w, f->h, f->d_w, f->d_h, f->imgfmt);
- }
}
static int control(vf_instance_t *vf, int request, void *data)