cleanup: Silence compilation warnings on MinGW-w64
[mplayer.git] / libmpcodecs / vf.h
blobd97e363778433e234e0b0131da7617b64492e173
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #ifndef MPLAYER_VF_H
20 #define MPLAYER_VF_H
22 #include "mp_image.h"
23 #include "mpcommon.h"
24 #include "stdbool.h"
26 #include "mpc_info.h"
27 #include "vfcap.h"
29 struct MPOpts;
30 struct vf_instance;
31 struct vf_priv_s;
33 typedef struct vf_info {
34 const char *info;
35 const char *name;
36 const char *author;
37 const char *comment;
38 int (*vf_open)(struct vf_instance *vf, char *args);
39 // Ptr to a struct dscribing the options
40 const void *opts;
41 } vf_info_t;
43 #define NUM_NUMBERED_MPI 50
45 struct vf_image_context {
46 mp_image_t *static_images[2];
47 mp_image_t *temp_images[1];
48 mp_image_t *export_images[1];
49 mp_image_t *numbered_images[NUM_NUMBERED_MPI];
50 int static_idx;
53 struct vf_format_context {
54 int have_configured;
55 int orig_width, orig_height, orig_fmt;
58 typedef struct vf_instance {
59 const vf_info_t *info;
60 // funcs:
61 int (*config)(struct vf_instance *vf,
62 int width, int height, int d_width, int d_height,
63 unsigned int flags, unsigned int outfmt);
64 int (*control)(struct vf_instance *vf, int request, void *data);
65 int (*query_format)(struct vf_instance *vf, unsigned int fmt);
66 void (*get_image)(struct vf_instance *vf, mp_image_t *mpi);
67 int (*put_image)(struct vf_instance *vf, mp_image_t *mpi, double pts);
68 void (*start_slice)(struct vf_instance *vf, mp_image_t *mpi);
69 void (*draw_slice)(struct vf_instance *vf, unsigned char **src,
70 int *stride, int w, int h, int x, int y);
71 void (*uninit)(struct vf_instance *vf);
73 int (*continue_buffered_image)(struct vf_instance *vf);
74 // caps:
75 unsigned int default_caps; // used by default query_format()
76 unsigned int default_reqs; // used by default config()
77 // data:
78 int w, h;
79 struct vf_image_context imgctx;
80 struct vf_format_context fmt;
81 struct vf_instance *next;
82 mp_image_t *dmpi;
83 struct vf_priv_s *priv;
84 struct MPOpts *opts;
85 } vf_instance_t;
87 typedef struct vf_seteq {
88 const char *item;
89 int value;
90 } vf_equalizer_t;
92 struct vf_ctrl_screenshot {
93 // When the screenshot is complete, pass it to this callback.
94 void (*image_callback)(void *, mp_image_t *);
95 void *image_callback_ctx;
98 #define VFCTRL_QUERY_MAX_PP_LEVEL 4 // query max postprocessing level (if any)
99 #define VFCTRL_SET_PP_LEVEL 5 // set postprocessing level
100 #define VFCTRL_SET_EQUALIZER 6 // set color options (brightness,contrast etc)
101 #define VFCTRL_GET_EQUALIZER 8 // get color options (brightness,contrast etc)
102 #define VFCTRL_DRAW_OSD 7
103 #define VFCTRL_CHANGE_RECTANGLE 9 // vf_rectangle control
104 #define VFCTRL_DUPLICATE_FRAME 11 // For encoding - encode zero-change frame
105 #define VFCTRL_SKIP_NEXT_FRAME 12 // For encoding - drop the next frame that passes thru
106 #define VFCTRL_FLUSH_FRAMES 13 // For encoding - flush delayed frames
107 #define VFCTRL_SCREENSHOT 14 // Take screenshot, arg is vf_ctrl_screenshot
108 #define VFCTRL_INIT_EOSD 15 // Select EOSD renderer
109 #define VFCTRL_DRAW_EOSD 16 // Render EOSD */
110 #define VFCTRL_SET_DEINTERLACE 18 // Set deinterlacing status
111 #define VFCTRL_GET_DEINTERLACE 19 // Get deinterlacing status
112 /* Hack to make the OSD state object available to vf_expand and vf_ass which
113 * access OSD/subtitle state outside of normal OSD draw time. */
114 #define VFCTRL_SET_OSD_OBJ 20
115 #define VFCTRL_SET_YUV_COLORSPACE 22 // arg is struct mp_csp_details*
116 #define VFCTRL_GET_YUV_COLORSPACE 23 // arg is struct mp_csp_details*
118 // functions:
119 void vf_mpi_clear(mp_image_t *mpi, int x0, int y0, int w, int h);
120 mp_image_t *vf_get_image(vf_instance_t *vf, unsigned int outfmt,
121 int mp_imgtype, int mp_imgflag, int w, int h);
123 vf_instance_t *vf_open_plugin(struct MPOpts *opts,
124 const vf_info_t * const *filter_list, vf_instance_t *next,
125 const char *name, char **args);
126 struct vf_instance *vf_open_plugin_noerr(struct MPOpts *opts,
127 const vf_info_t *const *filter_list, vf_instance_t *next,
128 const char *name, char **args, int *retcode);
129 vf_instance_t *vf_open_filter(struct MPOpts *opts, vf_instance_t *next,
130 const char *name, char **args);
131 vf_instance_t *vf_add_before_vo(vf_instance_t **vf, char *name, char **args);
132 vf_instance_t *vf_open_encoder(struct MPOpts *opts, vf_instance_t *next,
133 const char *name, char *args);
135 unsigned int vf_match_csp(vf_instance_t **vfp, const unsigned int *list,
136 unsigned int preferred);
137 void vf_clone_mpi_attributes(mp_image_t *dst, mp_image_t *src);
138 void vf_queue_frame(vf_instance_t *vf, int (*)(vf_instance_t *));
139 int vf_output_queued_frame(vf_instance_t *vf);
141 // default wrappers:
142 int vf_next_config(struct vf_instance *vf,
143 int width, int height, int d_width, int d_height,
144 unsigned int flags, unsigned int outfmt);
145 int vf_next_control(struct vf_instance *vf, int request, void *data);
146 int vf_next_query_format(struct vf_instance *vf, unsigned int fmt);
147 int vf_next_put_image(struct vf_instance *vf, mp_image_t *mpi, double pts);
148 void vf_next_draw_slice(struct vf_instance *vf, unsigned char **src,
149 int *stride, int w, int h, int x, int y);
151 struct m_obj_settings;
152 vf_instance_t *append_filters(vf_instance_t *last,
153 struct m_obj_settings *vf_settings);
155 void vf_uninit_filter(vf_instance_t *vf);
156 void vf_uninit_filter_chain(vf_instance_t *vf);
158 int vf_config_wrapper(struct vf_instance *vf,
159 int width, int height, int d_width, int d_height,
160 unsigned int flags, unsigned int outfmt);
162 static inline int norm_qscale(int qscale, int type)
164 switch (type) {
165 case 0: // MPEG-1
166 return qscale;
167 case 1: // MPEG-2
168 return qscale >> 1;
169 case 2: // H264
170 return qscale >> 2;
171 case 3: // VP56
172 return (63 - qscale + 2) >> 2;
174 return qscale;
177 struct vf_detc_pts_buf {
178 double inpts_prev, outpts_prev;
179 double lastdelta;
181 void vf_detc_init_pts_buf(struct vf_detc_pts_buf *p);
182 /* Adjust pts when detelecining.
183 * skip_frame: do not render this frame
184 * reset_pattern: set to 1 if the telecine pattern has reset due to scene cut
186 double vf_detc_adjust_pts(struct vf_detc_pts_buf *p, double pts,
187 bool reset_pattern, bool skip_frame);
188 double vf_softpulldown_adjust_pts(struct vf_detc_pts_buf *p, double pts,
189 bool reset_pattern, bool skip_frame,
190 int last_frame_duration);
192 #endif /* MPLAYER_VF_H */