vf.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * This file is part of MPlayer.
  3. *
  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.
  8. *
  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.
  13. *
  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.
  17. */
  18. #ifndef MPLAYER_VF_H
  19. #define MPLAYER_VF_H
  20. //#include "m_option.h"
  21. #include "mp_image.h"
  22. //extern m_obj_settings_t* vf_settings;
  23. //extern const m_obj_list_t vf_obj_list;
  24. struct vf_instance;
  25. struct vf_priv_s;
  26. typedef struct vf_info_s {
  27. const char *info;
  28. const char *name;
  29. const char *author;
  30. const char *comment;
  31. int (*vf_open)(struct vf_instance *vf,char* args);
  32. // Ptr to a struct dscribing the options
  33. const void* opts;
  34. } vf_info_t;
  35. #define NUM_NUMBERED_MPI 50
  36. typedef struct vf_image_context_s {
  37. mp_image_t* static_images[2];
  38. mp_image_t* temp_images[1];
  39. mp_image_t* export_images[1];
  40. mp_image_t* numbered_images[NUM_NUMBERED_MPI];
  41. int static_idx;
  42. } vf_image_context_t;
  43. typedef struct vf_format_context_t {
  44. int have_configured;
  45. int orig_width, orig_height, orig_fmt;
  46. } vf_format_context_t;
  47. typedef struct vf_instance {
  48. const vf_info_t* info;
  49. // funcs:
  50. int (*config)(struct vf_instance *vf,
  51. int width, int height, int d_width, int d_height,
  52. unsigned int flags, unsigned int outfmt);
  53. int (*control)(struct vf_instance *vf,
  54. int request, void* data);
  55. int (*query_format)(struct vf_instance *vf,
  56. unsigned int fmt);
  57. void (*get_image)(struct vf_instance *vf,
  58. mp_image_t *mpi);
  59. int (*put_image)(struct vf_instance *vf,
  60. mp_image_t *mpi, double pts);
  61. void (*start_slice)(struct vf_instance *vf,
  62. mp_image_t *mpi);
  63. void (*draw_slice)(struct vf_instance *vf,
  64. unsigned char** src, int* stride, int w,int h, int x, int y);
  65. void (*uninit)(struct vf_instance *vf);
  66. int (*continue_buffered_image)(struct vf_instance *vf);
  67. // caps:
  68. unsigned int default_caps; // used by default query_format()
  69. unsigned int default_reqs; // used by default config()
  70. // data:
  71. int w, h;
  72. vf_image_context_t imgctx;
  73. vf_format_context_t fmt;
  74. struct vf_instance *next;
  75. mp_image_t *dmpi;
  76. struct vf_priv_s* priv;
  77. } vf_instance_t;
  78. // control codes:
  79. #include "mpc_info.h"
  80. typedef struct vf_seteq_s
  81. {
  82. const char *item;
  83. int value;
  84. } vf_equalizer_t;
  85. #define VFCTRL_QUERY_MAX_PP_LEVEL 4 /* test for postprocessing support (max level) */
  86. #define VFCTRL_SET_PP_LEVEL 5 /* set postprocessing level */
  87. #define VFCTRL_SET_EQUALIZER 6 /* set color options (brightness,contrast etc) */
  88. #define VFCTRL_GET_EQUALIZER 8 /* gset color options (brightness,contrast etc) */
  89. #define VFCTRL_DRAW_OSD 7
  90. #define VFCTRL_CHANGE_RECTANGLE 9 /* Change the rectangle boundaries */
  91. #define VFCTRL_FLIP_PAGE 10 /* Tell the vo to flip pages */
  92. #define VFCTRL_DUPLICATE_FRAME 11 /* For encoding - encode zero-change frame */
  93. #define VFCTRL_SKIP_NEXT_FRAME 12 /* For encoding - drop the next frame that passes thru */
  94. #define VFCTRL_FLUSH_FRAMES 13 /* For encoding - flush delayed frames */
  95. #define VFCTRL_SCREENSHOT 14 /* Make a screenshot */
  96. #define VFCTRL_INIT_EOSD 15 /* Select EOSD renderer */
  97. #define VFCTRL_DRAW_EOSD 16 /* Render EOSD */
  98. #define VFCTRL_GET_PTS 17 /* Return last pts value that reached vf_vo*/
  99. #define VFCTRL_SET_DEINTERLACE 18 /* Set deinterlacing status */
  100. #define VFCTRL_GET_DEINTERLACE 19 /* Get deinterlacing status */
  101. #include "vfcap.h"
  102. //FIXME this should be in a common header, but i dunno which
  103. #define MP_NOPTS_VALUE (-1LL<<63) //both int64_t and double should be able to represent this exactly
  104. // functions:
  105. void vf_mpi_clear(mp_image_t* mpi,int x0,int y0,int w,int h);
  106. mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h);
  107. vf_instance_t* vf_open_plugin(const vf_info_t* const* filter_list, vf_instance_t* next, const char *name, char **args);
  108. vf_instance_t* vf_open_filter(vf_instance_t* next, const char *name, char **args);
  109. vf_instance_t* vf_add_before_vo(vf_instance_t **vf, char *name, char **args);
  110. vf_instance_t* vf_open_encoder(vf_instance_t* next, const char *name, char *args);
  111. unsigned int vf_match_csp(vf_instance_t** vfp,const unsigned int* list,unsigned int preferred);
  112. void vf_clone_mpi_attributes(mp_image_t* dst, mp_image_t* src);
  113. void vf_queue_frame(vf_instance_t *vf, int (*)(vf_instance_t *));
  114. int vf_output_queued_frame(vf_instance_t *vf);
  115. // default wrappers:
  116. int vf_next_config(struct vf_instance *vf,
  117. int width, int height, int d_width, int d_height,
  118. unsigned int flags, unsigned int outfmt);
  119. int vf_next_control(struct vf_instance *vf, int request, void* data);
  120. void vf_extra_flip(struct vf_instance *vf);
  121. int vf_next_query_format(struct vf_instance *vf, unsigned int fmt);
  122. int vf_next_put_image(struct vf_instance *vf,mp_image_t *mpi, double pts);
  123. void vf_next_draw_slice (struct vf_instance *vf, unsigned char** src, int* stride, int w,int h, int x, int y);
  124. vf_instance_t* append_filters(vf_instance_t* last);
  125. void vf_uninit_filter(vf_instance_t* vf);
  126. void vf_uninit_filter_chain(vf_instance_t* vf);
  127. int vf_config_wrapper(struct vf_instance *vf,
  128. int width, int height, int d_width, int d_height,
  129. unsigned int flags, unsigned int outfmt);
  130. static inline int norm_qscale(int qscale, int type)
  131. {
  132. switch (type) {
  133. case 0: // MPEG-1
  134. return qscale;
  135. case 1: // MPEG-2
  136. return qscale >> 1;
  137. case 2: // H264
  138. return qscale >> 2;
  139. case 3: // VP56
  140. return (63 - qscale + 2) >> 2;
  141. }
  142. return qscale;
  143. }
  144. #endif /* MPLAYER_VF_H */