Merge branch 'mplayer1_changes'
[mplayer.git] / libmpcodecs / vf.h
blobec1a9c23fffc0968d23115c15a4816a2144e54f1
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 struct MPOpts;
27 struct vf_instance;
28 struct vf_priv_s;
30 typedef struct vf_info {
31 const char *info;
32 const char *name;
33 const char *author;
34 const char *comment;
35 int (*vf_open)(struct vf_instance *vf,char* args);
36 // Ptr to a struct dscribing the options
37 const void* opts;
38 } vf_info_t;
40 #define NUM_NUMBERED_MPI 50
42 typedef struct vf_image_context_s {
43 mp_image_t* static_images[2];
44 mp_image_t* temp_images[1];
45 mp_image_t* export_images[1];
46 mp_image_t* numbered_images[NUM_NUMBERED_MPI];
47 int static_idx;
48 } vf_image_context_t;
50 typedef struct vf_format_context_t {
51 int have_configured;
52 int orig_width, orig_height, orig_fmt;
53 } vf_format_context_t;
55 typedef struct vf_instance {
56 const vf_info_t* info;
57 // funcs:
58 int (*config)(struct vf_instance *vf,
59 int width, int height, int d_width, int d_height,
60 unsigned int flags, unsigned int outfmt);
61 int (*control)(struct vf_instance *vf,
62 int request, void* data);
63 int (*query_format)(struct vf_instance *vf,
64 unsigned int fmt);
65 void (*get_image)(struct vf_instance *vf,
66 mp_image_t *mpi);
67 int (*put_image)(struct vf_instance *vf,
68 mp_image_t *mpi, double pts);
69 void (*start_slice)(struct vf_instance *vf,
70 mp_image_t *mpi);
71 void (*draw_slice)(struct vf_instance *vf,
72 unsigned char** src, int* stride, int w,int h, int x, int y);
73 void (*uninit)(struct vf_instance *vf);
75 int (*continue_buffered_image)(struct vf_instance *vf);
76 // caps:
77 unsigned int default_caps; // used by default query_format()
78 unsigned int default_reqs; // used by default config()
79 // data:
80 int w, h;
81 vf_image_context_t imgctx;
82 vf_format_context_t fmt;
83 struct vf_instance *next;
84 mp_image_t *dmpi;
85 struct vf_priv_s* priv;
86 struct MPOpts *opts;
87 } vf_instance_t;
89 // control codes:
90 #include "mpc_info.h"
92 typedef struct vf_seteq_s
94 const char *item;
95 int value;
96 } vf_equalizer_t;
98 #define VFCTRL_QUERY_MAX_PP_LEVEL 4 /* test for postprocessing support (max level) */
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 /* gset color options (brightness,contrast etc) */
102 #define VFCTRL_DRAW_OSD 7
103 #define VFCTRL_CHANGE_RECTANGLE 9 /* Change the rectangle boundaries */
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 /* Make a 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_REDRAW_OSD 21 /* Change user-visible OSD immediately */
116 #define VFCTRL_SET_YUV_COLORSPACE 22
117 #define VFCTRL_GET_YUV_COLORSPACE 23
119 #include "vfcap.h"
121 // functions:
122 void vf_mpi_clear(mp_image_t* mpi,int x0,int y0,int w,int h);
123 mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h);
125 vf_instance_t* vf_open_plugin(struct MPOpts *opts, const vf_info_t* const* filter_list, vf_instance_t* next, const char *name, char **args);
126 struct vf_instance *vf_open_plugin_noerr(struct MPOpts *opts,
127 const vf_info_t * const *filter_list,
128 vf_instance_t *next, const char *name,
129 char **args, int *retcode);
130 vf_instance_t* vf_open_filter(struct MPOpts *opts, vf_instance_t* next, 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, const char *name, char *args);
134 unsigned int vf_match_csp(vf_instance_t** vfp,const unsigned int* list,unsigned int preferred);
135 void vf_clone_mpi_attributes(mp_image_t* dst, mp_image_t* src);
136 void vf_queue_frame(vf_instance_t *vf, int (*)(vf_instance_t *));
137 int vf_output_queued_frame(vf_instance_t *vf);
139 // default wrappers:
140 int vf_next_config(struct vf_instance *vf,
141 int width, int height, int d_width, int d_height,
142 unsigned int flags, unsigned int outfmt);
143 int vf_next_control(struct vf_instance *vf, int request, void* data);
144 int vf_next_query_format(struct vf_instance *vf, unsigned int fmt);
145 int vf_next_put_image(struct vf_instance *vf,mp_image_t *mpi, double pts);
146 void vf_next_draw_slice (struct vf_instance *vf, unsigned char** src, int* stride, int w,int h, int x, int y);
148 struct m_obj_settings;
149 vf_instance_t* append_filters(vf_instance_t* last, struct m_obj_settings *vf_settings);
151 void vf_uninit_filter(vf_instance_t* vf);
152 void vf_uninit_filter_chain(vf_instance_t* vf);
154 int vf_config_wrapper(struct vf_instance *vf,
155 int width, int height, int d_width, int d_height,
156 unsigned int flags, unsigned int outfmt);
158 static inline int norm_qscale(int qscale, int type)
160 switch (type) {
161 case 0: // MPEG-1
162 return qscale;
163 case 1: // MPEG-2
164 return qscale >> 1;
165 case 2: // H264
166 return qscale >> 2;
167 case 3: // VP56
168 return (63 - qscale + 2) >> 2;
170 return qscale;
173 struct vf_detc_pts_buf {
174 double inpts_prev, outpts_prev;
175 double lastdelta;
177 void vf_detc_init_pts_buf(struct vf_detc_pts_buf *p);
178 /* Adjust pts when detelecining.
179 * skip_frame: do not render this frame
180 * reset_pattern: set to 1 if the telecine pattern has reset due to scene cut
182 double vf_detc_adjust_pts(struct vf_detc_pts_buf *p, double pts,
183 bool reset_pattern, bool skip_frame);
184 double vf_softpulldown_adjust_pts(struct vf_detc_pts_buf *p, double pts,
185 bool reset_pattern, bool skip_frame,
186 int last_frame_duration);
188 #endif /* MPLAYER_VF_H */