diff options
author | Niklas Haas <git@haasn.xyz> | 2017-09-14 08:04:55 +0200 |
---|---|---|
committer | Niklas Haas <git@haasn.xyz> | 2017-09-21 15:00:55 +0200 |
commit | 65979986a923a8f08019b257c3fe72cd5e8ecf68 (patch) | |
tree | b8f4b8c17d583594aef0ca509064f8b2ff7128d4 /video/out/gpu/video.h | |
parent | 20f958c9775652c3213588c2a0824f5353276adc (diff) | |
download | mpv-65979986a923a8f08019b257c3fe72cd5e8ecf68.tar.bz2 mpv-65979986a923a8f08019b257c3fe72cd5e8ecf68.tar.xz |
vo_opengl: refactor into vo_gpu
This is done in several steps:
1. refactor MPGLContext -> struct ra_ctx
2. move GL-specific stuff in vo_opengl into opengl/context.c
3. generalize context creation to support other APIs, and add --gpu-api
4. rename all of the --opengl- options that are no longer opengl-specific
5. move all of the stuff from opengl/* that isn't GL-specific into gpu/
(note: opengl/gl_utils.h became opengl/utils.h)
6. rename vo_opengl to vo_gpu
7. to handle window screenshots, the short-term approach was to just add
it to ra_swchain_fns. Long term (and for vulkan) this has to be moved to
ra itself (and vo_gpu altered to compensate), but this was a stop-gap
measure to prevent this commit from getting too big
8. move ra->fns->flush to ra_gl_ctx instead
9. some other minor changes that I've probably already forgotten
Note: This is one half of a major refactor, the other half of which is
provided by rossy's following commit. This commit enables support for
all linux platforms, while his version enables support for all non-linux
platforms.
Note 2: vo_opengl_cb.c also re-uses ra_gl_ctx so it benefits from the
--opengl- options like --opengl-early-flush, --opengl-finish etc. Should
be a strict superset of the old functionality.
Disclaimer: Since I have no way of compiling mpv on all platforms, some
of these ports were done blindly. Specifically, the blind ports included
context_mali_fbdev.c and context_rpi.c. Since they're both based on
egl_helpers, the port should have gone smoothly without any major
changes required. But if somebody complains about a compile error on
those platforms (assuming anybody actually uses them), you know where to
complain.
Diffstat (limited to 'video/out/gpu/video.h')
-rw-r--r-- | video/out/gpu/video.h | 194 |
1 files changed, 194 insertions, 0 deletions
diff --git a/video/out/gpu/video.h b/video/out/gpu/video.h new file mode 100644 index 0000000000..884f5914fd --- /dev/null +++ b/video/out/gpu/video.h @@ -0,0 +1,194 @@ +/* + * This file is part of mpv. + * + * mpv is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * mpv 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with mpv. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef MP_GL_VIDEO_H +#define MP_GL_VIDEO_H + +#include <stdbool.h> + +#include "options/m_option.h" +#include "sub/osd.h" +#include "utils.h" +#include "lcms.h" +#include "shader_cache.h" +#include "video/csputils.h" +#include "video/out/filter_kernels.h" + +// Assume we have this many texture units for sourcing additional passes. +// The actual texture unit assignment is dynamic. +#define TEXUNIT_VIDEO_NUM 6 + +struct scaler_fun { + char *name; + float params[2]; + float blur; + float taper; +}; + +struct scaler_config { + struct scaler_fun kernel; + struct scaler_fun window; + float radius; + float antiring; + float cutoff; + float clamp; +}; + +struct scaler { + int index; + struct scaler_config conf; + double scale_factor; + bool initialized; + struct filter_kernel *kernel; + struct ra_tex *lut; + struct fbotex sep_fbo; + bool insufficient; + int lut_size; + + // kernel points here + struct filter_kernel kernel_storage; +}; + +enum scaler_unit { + SCALER_SCALE, // luma/video + SCALER_DSCALE, // luma-video downscaling + SCALER_CSCALE, // chroma upscaling + SCALER_TSCALE, // temporal scaling (interpolation) + SCALER_COUNT +}; + +enum dither_algo { + DITHER_NONE = 0, + DITHER_FRUIT, + DITHER_ORDERED, +}; + +enum alpha_mode { + ALPHA_NO = 0, + ALPHA_YES, + ALPHA_BLEND, + ALPHA_BLEND_TILES, +}; + +enum blend_subs_mode { + BLEND_SUBS_NO = 0, + BLEND_SUBS_YES, + BLEND_SUBS_VIDEO, +}; + +enum tone_mapping { + TONE_MAPPING_CLIP, + TONE_MAPPING_MOBIUS, + TONE_MAPPING_REINHARD, + TONE_MAPPING_HABLE, + TONE_MAPPING_GAMMA, + TONE_MAPPING_LINEAR, +}; + +// How many frames to average over for HDR peak detection +#define PEAK_DETECT_FRAMES 100 + +struct gl_video_opts { + int dumb_mode; + struct scaler_config scaler[4]; + int scaler_lut_size; + float gamma; + int gamma_auto; + int target_prim; + int target_trc; + int target_brightness; + int tone_mapping; + int compute_hdr_peak; + float tone_mapping_param; + float tone_mapping_desat; + int gamut_warning; + int linear_scaling; + int correct_downscaling; + int sigmoid_upscaling; + float sigmoid_center; + float sigmoid_slope; + int scaler_resizes_only; + int pbo; + int dither_depth; + int dither_algo; + int dither_size; + int temporal_dither; + int temporal_dither_period; + char *fbo_format; + int alpha_mode; + int use_rectangle; + struct m_color background; + int interpolation; + float interpolation_threshold; + int blend_subs; + char **user_shaders; + int deband; + struct deband_opts *deband_opts; + float unsharp; + int tex_pad_x, tex_pad_y; + struct mp_icc_opts *icc_opts; + int early_flush; + char *shader_cache_dir; +}; + +extern const struct m_sub_options gl_video_conf; + +struct gl_video; +struct vo_frame; + +struct gl_video *gl_video_init(struct ra *ra, struct mp_log *log, + struct mpv_global *g); +void gl_video_uninit(struct gl_video *p); +void gl_video_set_osd_source(struct gl_video *p, struct osd_state *osd); +void gl_video_update_options(struct gl_video *p); +bool gl_video_check_format(struct gl_video *p, int mp_format); +void gl_video_config(struct gl_video *p, struct mp_image_params *params); +void gl_video_set_output_depth(struct gl_video *p, int r, int g, int b); +void gl_video_render_frame(struct gl_video *p, struct vo_frame *frame, + struct fbodst target); +void gl_video_resize(struct gl_video *p, + struct mp_rect *src, struct mp_rect *dst, + struct mp_osd_res *osd); +void gl_video_set_fb_depth(struct gl_video *p, int fb_depth); +void gl_video_perfdata(struct gl_video *p, struct voctrl_performance_data *out); +void gl_video_set_clear_color(struct gl_video *p, struct m_color color); +void gl_video_set_osd_pts(struct gl_video *p, double pts); +bool gl_video_check_osd_change(struct gl_video *p, struct mp_osd_res *osd, + double pts); + +float gl_video_scale_ambient_lux(float lmin, float lmax, + float rmin, float rmax, float lux); +void gl_video_set_ambient_lux(struct gl_video *p, int lux); +void gl_video_set_icc_profile(struct gl_video *p, bstr icc_data); +bool gl_video_icc_auto_enabled(struct gl_video *p); +bool gl_video_gamma_auto_enabled(struct gl_video *p); +struct mp_colorspace gl_video_get_output_colorspace(struct gl_video *p); + +void gl_video_reset(struct gl_video *p); +bool gl_video_showing_interpolated_frame(struct gl_video *p); + +struct ra_hwdec; +void gl_video_set_hwdec(struct gl_video *p, struct ra_hwdec *hwdec); + +struct vo; +void gl_video_configure_queue(struct gl_video *p, struct vo *vo); + +struct mp_image *gl_video_get_image(struct gl_video *p, int imgfmt, int w, int h, + int stride_align); + + +#endif |