2010-01-30 16:57:40 +00:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#ifndef MPLAYER_VF_H
|
|
|
|
#define MPLAYER_VF_H
|
2002-04-06 22:05:01 +00:00
|
|
|
|
2012-11-09 00:06:43 +00:00
|
|
|
#include <stdbool.h>
|
2008-03-06 08:34:50 +00:00
|
|
|
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "video/mp_image.h"
|
2013-08-06 20:41:30 +00:00
|
|
|
#include "mpvcore/mp_common.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
|
|
|
|
#include "video/vfcap.h"
|
2011-11-03 13:21:53 +00:00
|
|
|
|
2008-04-16 04:06:44 +00:00
|
|
|
struct MPOpts;
|
2008-04-24 02:49:44 +00:00
|
|
|
struct vf_instance;
|
2002-04-06 22:05:01 +00:00
|
|
|
struct vf_priv_s;
|
|
|
|
|
2010-10-30 04:18:49 +00:00
|
|
|
typedef struct vf_info {
|
2013-10-23 17:06:42 +00:00
|
|
|
const char *description;
|
2002-04-06 22:05:01 +00:00
|
|
|
const char *name;
|
2013-10-23 17:06:42 +00:00
|
|
|
int (*open)(struct vf_instance *vf, char *args);
|
options: use m_config for options instead of m_struct
For some reason, both m_config and m_struct are somewhat similar, except
that m_config is much more powerful. m_config is used for VOs and some
other things, so to unify them. We plan to kick out m_struct and use
m_config for everything. (Unfortunately, m_config is also a bit more
bloated, so this commit isn't all that great, but it will allow to
reduce the option parser mess somewhat.)
This commit also switches all video filters to use the option macros.
One reason is that m_struct and m_config, even though they both use
m_option, store the offsets of the option fields differently (sigh...),
meaning the options defined for either are incompatible. It's easier to
switch everything in one go.
This commit will allow using the -vf option parser for other things,
like VOs and AOs.
2013-07-21 17:33:08 +00:00
|
|
|
void *damn_you;
|
|
|
|
int priv_size;
|
|
|
|
const void *priv_defaults;
|
|
|
|
const struct m_option *options;
|
2002-04-06 22:05:01 +00:00
|
|
|
} vf_info_t;
|
|
|
|
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
struct vf_format {
|
|
|
|
int configured;
|
2013-06-07 23:35:44 +00:00
|
|
|
struct mp_image_params params;
|
|
|
|
int flags;
|
2011-11-03 13:21:53 +00:00
|
|
|
};
|
2005-03-01 20:21:58 +00:00
|
|
|
|
2008-04-24 02:49:44 +00:00
|
|
|
typedef struct vf_instance {
|
2011-11-03 13:21:53 +00:00
|
|
|
const vf_info_t *info;
|
2013-06-07 23:35:44 +00:00
|
|
|
|
2010-05-29 14:15:55 +00:00
|
|
|
int (*config)(struct vf_instance *vf,
|
2011-11-03 13:21:53 +00:00
|
|
|
int width, int height, int d_width, int d_height,
|
|
|
|
unsigned int flags, unsigned int outfmt);
|
2013-06-07 23:35:44 +00:00
|
|
|
|
|
|
|
// Alternative to config() (can pass more image parameters)
|
|
|
|
// Note: the callee is allowed to write *params.
|
|
|
|
int (*reconfig)(struct vf_instance *vf, struct mp_image_params *params,
|
|
|
|
int flags);
|
|
|
|
|
2011-11-03 13:21:53 +00:00
|
|
|
int (*control)(struct vf_instance *vf, int request, void *data);
|
|
|
|
int (*query_format)(struct vf_instance *vf, unsigned int fmt);
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
|
|
|
|
// Filter mpi and return the result. The input mpi reference is owned by
|
|
|
|
// the filter, the returned reference is owned by the caller.
|
|
|
|
// Return NULL if the output frame is skipped.
|
|
|
|
struct mp_image *(*filter)(struct vf_instance *vf, struct mp_image *mpi);
|
|
|
|
|
|
|
|
// Like filter(), but can return an error code ( >= 0 means success). This
|
|
|
|
// callback is also more practical when the filter can return multiple
|
|
|
|
// output images. Use vf_add_output_frame() to queue output frames.
|
|
|
|
int (*filter_ext)(struct vf_instance *vf, struct mp_image *mpi);
|
|
|
|
|
2010-05-29 14:15:55 +00:00
|
|
|
void (*uninit)(struct vf_instance *vf);
|
2006-07-06 06:58:17 +00:00
|
|
|
|
2013-05-22 21:19:57 +00:00
|
|
|
char *label;
|
|
|
|
|
2002-04-06 22:05:01 +00:00
|
|
|
// data:
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
struct vf_format fmt_in, fmt_out;
|
2010-05-29 14:15:55 +00:00
|
|
|
struct vf_instance *next;
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
|
|
|
|
struct mp_image_pool *out_pool;
|
2011-11-03 13:21:53 +00:00
|
|
|
struct vf_priv_s *priv;
|
2008-04-16 04:06:44 +00:00
|
|
|
struct MPOpts *opts;
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
|
|
|
|
struct mp_image **out_queued;
|
|
|
|
int num_out_queued;
|
2002-04-06 22:05:01 +00:00
|
|
|
} vf_instance_t;
|
|
|
|
|
2011-11-03 13:21:53 +00:00
|
|
|
typedef struct vf_seteq {
|
2007-12-02 15:22:06 +00:00
|
|
|
const char *item;
|
2002-07-28 21:30:09 +00:00
|
|
|
int value;
|
|
|
|
} vf_equalizer_t;
|
|
|
|
|
2013-10-02 19:19:16 +00:00
|
|
|
enum vf_ctrl {
|
|
|
|
VFCTRL_SEEK_RESET = 1, // reset on picture and PTS discontinuities
|
|
|
|
VFCTRL_QUERY_MAX_PP_LEVEL, // query max postprocessing level (if any)
|
|
|
|
VFCTRL_SET_PP_LEVEL, // set postprocessing level
|
|
|
|
VFCTRL_SET_EQUALIZER, // set color options (brightness,contrast etc)
|
|
|
|
VFCTRL_GET_EQUALIZER, // get color options (brightness,contrast etc)
|
|
|
|
VFCTRL_SCREENSHOT, // Take screenshot, arg is voctrl_screenshot_args
|
|
|
|
VFCTRL_INIT_OSD, // Filter OSD renderer present?
|
|
|
|
VFCTRL_SET_DEINTERLACE, // Set deinterlacing status
|
|
|
|
VFCTRL_GET_DEINTERLACE, // Get deinterlacing status
|
|
|
|
/* Hack to make the OSD state object available to vf_sub which
|
|
|
|
* access OSD/subtitle state outside of normal OSD draw time. */
|
|
|
|
VFCTRL_SET_OSD_OBJ,
|
|
|
|
VFCTRL_GET_HWDEC_INFO, // for hwdec filters
|
|
|
|
};
|
2002-04-11 15:41:40 +00:00
|
|
|
|
2013-07-14 22:57:04 +00:00
|
|
|
int vf_control(struct vf_instance *vf, int cmd, void *arg);
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
void vf_add_output_frame(struct vf_instance *vf, struct mp_image *img);
|
|
|
|
|
|
|
|
int vf_filter_frame(struct vf_instance *vf, struct mp_image *img);
|
|
|
|
struct mp_image *vf_chain_output_queued_frame(struct vf_instance *vf);
|
2013-01-20 02:03:40 +00:00
|
|
|
void vf_chain_seek_reset(struct vf_instance *vf);
|
2002-04-10 23:23:36 +00:00
|
|
|
|
2011-11-03 13:21:53 +00:00
|
|
|
vf_instance_t *vf_open_filter(struct MPOpts *opts, vf_instance_t *next,
|
|
|
|
const char *name, char **args);
|
|
|
|
vf_instance_t *vf_add_before_vo(vf_instance_t **vf, char *name, char **args);
|
|
|
|
|
|
|
|
unsigned int vf_match_csp(vf_instance_t **vfp, const unsigned int *list,
|
|
|
|
unsigned int preferred);
|
2002-04-11 20:56:17 +00:00
|
|
|
|
2002-04-06 22:05:01 +00:00
|
|
|
// default wrappers:
|
2010-05-29 14:15:55 +00:00
|
|
|
int vf_next_config(struct vf_instance *vf,
|
2011-11-03 13:21:53 +00:00
|
|
|
int width, int height, int d_width, int d_height,
|
|
|
|
unsigned int flags, unsigned int outfmt);
|
|
|
|
int vf_next_control(struct vf_instance *vf, int request, void *data);
|
2010-05-29 14:15:55 +00:00
|
|
|
int vf_next_query_format(struct vf_instance *vf, unsigned int fmt);
|
2002-04-06 22:05:01 +00:00
|
|
|
|
2013-06-07 23:35:44 +00:00
|
|
|
int vf_next_reconfig(struct vf_instance *vf, struct mp_image_params *params,
|
|
|
|
int flags);
|
|
|
|
|
2008-04-25 10:58:12 +00:00
|
|
|
struct m_obj_settings;
|
2011-11-03 13:21:53 +00:00
|
|
|
vf_instance_t *append_filters(vf_instance_t *last,
|
|
|
|
struct m_obj_settings *vf_settings);
|
2002-04-06 22:05:01 +00:00
|
|
|
|
2013-05-22 21:19:57 +00:00
|
|
|
vf_instance_t *vf_find_by_label(vf_instance_t *chain, const char *label);
|
|
|
|
|
2011-11-03 13:21:53 +00:00
|
|
|
void vf_uninit_filter(vf_instance_t *vf);
|
|
|
|
void vf_uninit_filter_chain(vf_instance_t *vf);
|
2002-04-20 22:24:19 +00:00
|
|
|
|
2013-07-27 19:16:34 +00:00
|
|
|
int vf_reconfig_wrapper(struct vf_instance *vf,
|
|
|
|
const struct mp_image_params *params, int flags);
|
2013-01-14 18:19:23 +00:00
|
|
|
void vf_print_filter_chain(int msglevel, struct vf_instance *vf);
|
2008-01-01 21:35:58 +00:00
|
|
|
|
2013-01-22 12:28:31 +00:00
|
|
|
void vf_rescale_dsize(int *d_width, int *d_height, int old_w, int old_h,
|
|
|
|
int new_w, int new_h);
|
2013-09-26 14:05:46 +00:00
|
|
|
void vf_set_dar(int *d_width, int *d_height, int w, int h, double dar);
|
2012-12-26 20:08:54 +00:00
|
|
|
|
2010-01-29 19:13:07 +00:00
|
|
|
static inline int norm_qscale(int qscale, int type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case 0: // MPEG-1
|
|
|
|
return qscale;
|
|
|
|
case 1: // MPEG-2
|
|
|
|
return qscale >> 1;
|
|
|
|
case 2: // H264
|
|
|
|
return qscale >> 2;
|
|
|
|
case 3: // VP56
|
|
|
|
return (63 - qscale + 2) >> 2;
|
|
|
|
}
|
|
|
|
return qscale;
|
|
|
|
}
|
|
|
|
|
vf_*: fix pts values passed to the next filter
Many video filters failed to calculate or even just pass through pts
values for their output frames. Fix this, and also make the two
remaining filters that called vf_next_put_image() twice for the same
input frame (vf_softpulldown, vf_telecine) use vf_queue_frame() so
that e.g. framestepping properly sees both frames.
Changed filters: vf_bmovl, vf_detc, vf_divtc, vf_filmdint, vf_ivtc,
vf_lavc, vf_phase, vf_pullup, vf_softpulldown, vf_telecine, vf_tile,
vf_tinterlace.
2011-04-23 16:56:47 +00:00
|
|
|
struct vf_detc_pts_buf {
|
|
|
|
double inpts_prev, outpts_prev;
|
|
|
|
double lastdelta;
|
|
|
|
};
|
|
|
|
void vf_detc_init_pts_buf(struct vf_detc_pts_buf *p);
|
|
|
|
/* Adjust pts when detelecining.
|
|
|
|
* skip_frame: do not render this frame
|
|
|
|
* reset_pattern: set to 1 if the telecine pattern has reset due to scene cut
|
|
|
|
*/
|
|
|
|
double vf_detc_adjust_pts(struct vf_detc_pts_buf *p, double pts,
|
|
|
|
bool reset_pattern, bool skip_frame);
|
|
|
|
double vf_softpulldown_adjust_pts(struct vf_detc_pts_buf *p, double pts,
|
|
|
|
bool reset_pattern, bool skip_frame,
|
|
|
|
int last_frame_duration);
|
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#endif /* MPLAYER_VF_H */
|