00001 /* 00002 * This file is part of MPlayer. 00003 * 00004 * MPlayer is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * MPlayer is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License along 00015 * with MPlayer; if not, write to the Free Software Foundation, Inc., 00016 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00017 */ 00018 00019 #ifndef MPLAYER_VF_H 00020 #define MPLAYER_VF_H 00021 00022 //#include "m_option.h" 00023 #include "mp_image.h" 00024 00025 //extern m_obj_settings_t* vf_settings; 00026 //extern const m_obj_list_t vf_obj_list; 00027 00028 struct vf_instance; 00029 struct vf_priv_s; 00030 00031 typedef struct vf_info_s { 00032 const char *info; 00033 const char *name; 00034 const char *author; 00035 const char *comment; 00036 int (*vf_open)(struct vf_instance *vf,char* args); 00037 // Ptr to a struct dscribing the options 00038 const void* opts; 00039 } vf_info_t; 00040 00041 #define NUM_NUMBERED_MPI 50 00042 00043 typedef struct vf_image_context_s { 00044 mp_image_t* static_images[2]; 00045 mp_image_t* temp_images[1]; 00046 mp_image_t* export_images[1]; 00047 mp_image_t* numbered_images[NUM_NUMBERED_MPI]; 00048 int static_idx; 00049 } vf_image_context_t; 00050 00051 typedef struct vf_format_context_t { 00052 int have_configured; 00053 int orig_width, orig_height, orig_fmt; 00054 } vf_format_context_t; 00055 00056 typedef struct vf_instance { 00057 const vf_info_t* info; 00058 // funcs: 00059 int (*config)(struct vf_instance *vf, 00060 int width, int height, int d_width, int d_height, 00061 unsigned int flags, unsigned int outfmt); 00062 int (*control)(struct vf_instance *vf, 00063 int request, void* data); 00064 int (*query_format)(struct vf_instance *vf, 00065 unsigned int fmt); 00066 void (*get_image)(struct vf_instance *vf, 00067 mp_image_t *mpi); 00068 int (*put_image)(struct vf_instance *vf, 00069 mp_image_t *mpi, double pts); 00070 void (*start_slice)(struct vf_instance *vf, 00071 mp_image_t *mpi); 00072 void (*draw_slice)(struct vf_instance *vf, 00073 unsigned char** src, int* stride, int w,int h, int x, int y); 00074 void (*uninit)(struct vf_instance *vf); 00075 00076 int (*continue_buffered_image)(struct vf_instance *vf); 00077 // caps: 00078 unsigned int default_caps; // used by default query_format() 00079 unsigned int default_reqs; // used by default config() 00080 // data: 00081 int w, h; 00082 vf_image_context_t imgctx; 00083 vf_format_context_t fmt; 00084 struct vf_instance *next; 00085 mp_image_t *dmpi; 00086 struct vf_priv_s* priv; 00087 } vf_instance_t; 00088 00089 // control codes: 00090 #include "mpc_info.h" 00091 00092 typedef struct vf_seteq_s 00093 { 00094 const char *item; 00095 int value; 00096 } vf_equalizer_t; 00097 00098 #define VFCTRL_QUERY_MAX_PP_LEVEL 4 /* test for postprocessing support (max level) */ 00099 #define VFCTRL_SET_PP_LEVEL 5 /* set postprocessing level */ 00100 #define VFCTRL_SET_EQUALIZER 6 /* set color options (brightness,contrast etc) */ 00101 #define VFCTRL_GET_EQUALIZER 8 /* gset color options (brightness,contrast etc) */ 00102 #define VFCTRL_DRAW_OSD 7 00103 #define VFCTRL_CHANGE_RECTANGLE 9 /* Change the rectangle boundaries */ 00104 #define VFCTRL_FLIP_PAGE 10 /* Tell the vo to flip pages */ 00105 #define VFCTRL_DUPLICATE_FRAME 11 /* For encoding - encode zero-change frame */ 00106 #define VFCTRL_SKIP_NEXT_FRAME 12 /* For encoding - drop the next frame that passes thru */ 00107 #define VFCTRL_FLUSH_FRAMES 13 /* For encoding - flush delayed frames */ 00108 #define VFCTRL_SCREENSHOT 14 /* Make a screenshot */ 00109 #define VFCTRL_INIT_EOSD 15 /* Select EOSD renderer */ 00110 #define VFCTRL_DRAW_EOSD 16 /* Render EOSD */ 00111 #define VFCTRL_GET_PTS 17 /* Return last pts value that reached vf_vo*/ 00112 #define VFCTRL_SET_DEINTERLACE 18 /* Set deinterlacing status */ 00113 #define VFCTRL_GET_DEINTERLACE 19 /* Get deinterlacing status */ 00114 00115 #include "vfcap.h" 00116 00117 //FIXME this should be in a common header, but i dunno which 00118 #define MP_NOPTS_VALUE (-1LL<<63) //both int64_t and double should be able to represent this exactly 00119 00120 00121 // functions: 00122 void vf_mpi_clear(mp_image_t* mpi,int x0,int y0,int w,int h); 00123 mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h); 00124 00125 vf_instance_t* vf_open_plugin(const vf_info_t* const* filter_list, vf_instance_t* next, const char *name, char **args); 00126 vf_instance_t* vf_open_filter(vf_instance_t* next, const char *name, char **args); 00127 vf_instance_t* vf_add_before_vo(vf_instance_t **vf, char *name, char **args); 00128 vf_instance_t* vf_open_encoder(vf_instance_t* next, const char *name, char *args); 00129 00130 unsigned int vf_match_csp(vf_instance_t** vfp,const unsigned int* list,unsigned int preferred); 00131 void vf_clone_mpi_attributes(mp_image_t* dst, mp_image_t* src); 00132 void vf_queue_frame(vf_instance_t *vf, int (*)(vf_instance_t *)); 00133 int vf_output_queued_frame(vf_instance_t *vf); 00134 00135 // default wrappers: 00136 int vf_next_config(struct vf_instance *vf, 00137 int width, int height, int d_width, int d_height, 00138 unsigned int flags, unsigned int outfmt); 00139 int vf_next_control(struct vf_instance *vf, int request, void* data); 00140 void vf_extra_flip(struct vf_instance *vf); 00141 int vf_next_query_format(struct vf_instance *vf, unsigned int fmt); 00142 int vf_next_put_image(struct vf_instance *vf,mp_image_t *mpi, double pts); 00143 void vf_next_draw_slice (struct vf_instance *vf, unsigned char** src, int* stride, int w,int h, int x, int y); 00144 00145 vf_instance_t* append_filters(vf_instance_t* last); 00146 00147 void vf_uninit_filter(vf_instance_t* vf); 00148 void vf_uninit_filter_chain(vf_instance_t* vf); 00149 00150 int vf_config_wrapper(struct vf_instance *vf, 00151 int width, int height, int d_width, int d_height, 00152 unsigned int flags, unsigned int outfmt); 00153 00154 static inline int norm_qscale(int qscale, int type) 00155 { 00156 switch (type) { 00157 case 0: // MPEG-1 00158 return qscale; 00159 case 1: // MPEG-2 00160 return qscale >> 1; 00161 case 2: // H264 00162 return qscale >> 2; 00163 case 3: // VP56 00164 return (63 - qscale + 2) >> 2; 00165 } 00166 return qscale; 00167 } 00168 00169 #endif /* MPLAYER_VF_H */