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.
This commit is contained in:
wm4 2013-12-07 19:33:11 +01:00
parent bb6165342d
commit 0af9ede546
4 changed files with 25 additions and 37 deletions

View File

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

View File

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

View File

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

View File

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