2013-03-01 20:19:20 +00:00
|
|
|
/*
|
|
|
|
* This file is part of mpv.
|
|
|
|
*
|
|
|
|
* mpv is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU 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>
|
|
|
|
|
2014-12-09 20:34:01 +00:00
|
|
|
#include "options/m_option.h"
|
2013-11-24 11:58:06 +00:00
|
|
|
#include "sub/osd.h"
|
2013-03-01 20:19:20 +00:00
|
|
|
#include "gl_common.h"
|
|
|
|
|
|
|
|
struct lut3d {
|
|
|
|
uint16_t *data;
|
|
|
|
int size[3];
|
|
|
|
};
|
|
|
|
|
vo_opengl: refactor scaler configuration
This merges all of the scaler-related options into a single
configuration struct, and also cleans up the way they're passed through
the code. (For example, the scaler index is no longer threaded through
pass_sample, just the scaler configuration itself, and there's no longer
duplication of the params etc.)
In addition, this commit makes scale-down more principled, and turns it
into a scaler in its own right - so there's no longer an ugly separation
between scale and scale-down in the code.
Finally, the radius stuff has been made more proper - filters always
have a radius now (there's no more radius -1), and get a new .resizable
attribute instead for when it's tunable.
User-visible changes:
1. scale-down has been renamed dscale and now has its own set of config
options (dscale-param1, dscale-radius) etc., instead of reusing
scale-param1 (which was arguably a bug).
2. The default radius is no longer fixed at 3, but instead uses that
filter's preferred radius by default. (Scalers with a default radius
other than 3 include sinc, gaussian, box and triangle)
3. scale-radius etc. now goes down to 0.5, rather than 1.0. 0.5 is the
smallest radius that theoretically makes sense, and indeed it's used
by at least one filter (nearest).
Apart from that, it should just be internal changes only.
Note that this sets up for the refactor discussed in #1720, which would
be to merge scaler and window configurations (include parameters etc.)
into a single, simplified string. In the code, this would now basically
just mean getting rid of all the OPT_FLOATRANGE etc. lines related to
scalers and replacing them by a single function that parses a string and
updates the struct scaler_config as appropriate.
2015-03-26 00:55:32 +00:00
|
|
|
struct scaler_fun {
|
|
|
|
char *name;
|
|
|
|
float params[2];
|
|
|
|
float blur;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct scaler_config {
|
|
|
|
struct scaler_fun kernel;
|
|
|
|
struct scaler_fun window;
|
|
|
|
float radius;
|
|
|
|
float antiring;
|
|
|
|
};
|
|
|
|
|
2013-03-01 20:19:20 +00:00
|
|
|
struct gl_video_opts {
|
vo_opengl: refactor scaler configuration
This merges all of the scaler-related options into a single
configuration struct, and also cleans up the way they're passed through
the code. (For example, the scaler index is no longer threaded through
pass_sample, just the scaler configuration itself, and there's no longer
duplication of the params etc.)
In addition, this commit makes scale-down more principled, and turns it
into a scaler in its own right - so there's no longer an ugly separation
between scale and scale-down in the code.
Finally, the radius stuff has been made more proper - filters always
have a radius now (there's no more radius -1), and get a new .resizable
attribute instead for when it's tunable.
User-visible changes:
1. scale-down has been renamed dscale and now has its own set of config
options (dscale-param1, dscale-radius) etc., instead of reusing
scale-param1 (which was arguably a bug).
2. The default radius is no longer fixed at 3, but instead uses that
filter's preferred radius by default. (Scalers with a default radius
other than 3 include sinc, gaussian, box and triangle)
3. scale-radius etc. now goes down to 0.5, rather than 1.0. 0.5 is the
smallest radius that theoretically makes sense, and indeed it's used
by at least one filter (nearest).
Apart from that, it should just be internal changes only.
Note that this sets up for the refactor discussed in #1720, which would
be to merge scaler and window configurations (include parameters etc.)
into a single, simplified string. In the code, this would now basically
just mean getting rid of all the OPT_FLOATRANGE etc. lines related to
scalers and replacing them by a single function that parses a string and
updates the struct scaler_config as appropriate.
2015-03-26 00:55:32 +00:00
|
|
|
struct scaler_config scaler[4];
|
vo_opengl: refactor shader generation (part 2)
This adds stuff related to gamma, linear light, sigmoid, BT.2020-CL,
etc, as well as color management. Also adds a new gamma function (gamma22).
This adds new parameters to configure the CMS settings, in particular
letting us target simple colorspaces without requiring usage of a 3DLUT.
This adds smoothmotion. Mostly working, but it's still sensitive to
timing issues. It's based on an actual queue now, but the queue size
is kept small to avoid larger amounts of latency.
Also makes “upscale before blending” the default strategy.
This is justified because the "render after blending" thing doesn't seme
to work consistently any way (introduces stutter due to the way vsync
timing works, or something), so this behavior is a bit closer to master
and makes pausing/unpausing less weird/jumpy.
This adds the remaining scalers, including bicubic_fast, sharpen3,
sharpen5, polar filters and antiringing. Apparently, sharpen3/5 also
consult scale-param1, which was undocumented in master.
This also implements cropping and chroma transformation, plus
rotation/flipping. These are inherently part of the same logic, although
it's a bit rough around the edges in some case, mainly due to the fallback
code paths (for bilinear scaling without indirection).
2015-03-12 21:18:16 +00:00
|
|
|
float gamma;
|
|
|
|
int gamma_auto;
|
|
|
|
int target_prim;
|
|
|
|
int target_trc;
|
2015-02-06 02:37:21 +00:00
|
|
|
int linear_scaling;
|
2013-03-01 20:19:20 +00:00
|
|
|
int fancy_downscaling;
|
2015-01-06 09:47:26 +00:00
|
|
|
int sigmoid_upscaling;
|
|
|
|
float sigmoid_center;
|
|
|
|
float sigmoid_slope;
|
2013-05-25 21:47:55 +00:00
|
|
|
int scaler_resizes_only;
|
2013-03-01 20:19:20 +00:00
|
|
|
int npot;
|
|
|
|
int pbo;
|
|
|
|
int dither_depth;
|
2013-05-25 23:48:39 +00:00
|
|
|
int dither_algo;
|
|
|
|
int dither_size;
|
|
|
|
int temporal_dither;
|
2013-03-01 20:19:20 +00:00
|
|
|
int fbo_format;
|
2013-09-19 14:55:56 +00:00
|
|
|
int alpha_mode;
|
vo_opengl: handle chroma location
Use the video decoder chroma location flags and render chroma locations
other than centered. Until now, we've always used the intuitive and
obvious centered chroma location, but H.264 uses something else.
FFmpeg provides a small overview in libavcodec/avcodec.h:
-----------
/**
* X X 3 4 X X are luma samples,
* 1 2 1-6 are possible chroma positions
* X X 5 6 X 0 is undefined/unknown position
*/
enum AVChromaLocation{
AVCHROMA_LOC_UNSPECIFIED = 0,
AVCHROMA_LOC_LEFT = 1, ///< mpeg2/4, h264 default
AVCHROMA_LOC_CENTER = 2, ///< mpeg1, jpeg, h263
AVCHROMA_LOC_TOPLEFT = 3, ///< DV
AVCHROMA_LOC_TOP = 4,
AVCHROMA_LOC_BOTTOMLEFT = 5,
AVCHROMA_LOC_BOTTOM = 6,
AVCHROMA_LOC_NB , ///< Not part of ABI
};
-----------
The visual difference is literally minimal, but since videophiles
apparently consider this detail as quality mark of a video renderer,
support it anyway. We don't bother with chroma locations other than
centered and left, though.
Not sure about correctness, but it's probably ok.
2013-06-08 00:15:24 +00:00
|
|
|
int chroma_location;
|
2013-12-01 22:39:13 +00:00
|
|
|
int use_rectangle;
|
2014-12-09 20:34:01 +00:00
|
|
|
struct m_color background;
|
2015-03-13 18:30:31 +00:00
|
|
|
int interpolation;
|
2015-03-23 01:42:19 +00:00
|
|
|
int blend_subs;
|
2013-03-01 20:19:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern const struct m_sub_options gl_video_conf;
|
2013-10-24 20:20:16 +00:00
|
|
|
extern const struct gl_video_opts gl_video_opts_hq_def;
|
2014-12-09 20:34:01 +00:00
|
|
|
extern const struct gl_video_opts gl_video_opts_def;
|
2013-03-01 20:19:20 +00:00
|
|
|
|
|
|
|
struct gl_video;
|
|
|
|
|
2015-03-23 15:32:59 +00:00
|
|
|
struct gl_video *gl_video_init(GL *gl, struct mp_log *log);
|
2013-03-01 20:19:20 +00:00
|
|
|
void gl_video_uninit(struct gl_video *p);
|
2015-03-23 15:32:59 +00:00
|
|
|
void gl_video_set_osd_source(struct gl_video *p, struct osd_state *osd);
|
2015-03-13 18:30:31 +00:00
|
|
|
void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts,
|
|
|
|
int *queue_size);
|
2013-11-03 23:00:18 +00:00
|
|
|
bool gl_video_check_format(struct gl_video *p, int mp_format);
|
2013-06-07 23:35:44 +00:00
|
|
|
void gl_video_config(struct gl_video *p, struct mp_image_params *params);
|
2013-03-01 20:19:20 +00:00
|
|
|
void gl_video_set_output_depth(struct gl_video *p, int r, int g, int b);
|
|
|
|
void gl_video_set_lut3d(struct gl_video *p, struct lut3d *lut3d);
|
2015-05-01 16:44:45 +00:00
|
|
|
void gl_video_set_image(struct gl_video *p, struct mp_image *img);
|
2014-11-23 19:06:05 +00:00
|
|
|
void gl_video_render_frame(struct gl_video *p, int fbo, struct frame_timing *t);
|
vo_opengl: refactor shader generation (part 1)
The basic idea is to use dynamically generated shaders instead of a
single monolithic file + a ton of ifdefs. Instead of having to setup
every aspect of it separately (like compiling shaders, setting uniforms,
perfoming the actual rendering steps, the GLSL parts), we generate the
GLSL on the fly, and perform the rendering at the same time. The GLSL
is regenerated every frame, but the actual compiled OpenGL-level shaders
are cached, which makes it fast again. Almost all logic can be in a
single place.
The new code is significantly more flexible, which allows us to improve
the code clarity, performance and add more features easily.
This commit is incomplete. It drops almost all previous code, and
readds only the most important things (some of them actually buggy).
The next commit will complete it - it's separate to preserve authorship
information.
2015-03-12 20:57:54 +00:00
|
|
|
void gl_video_resize(struct gl_video *p, int vp_w, int vp_h,
|
2013-03-01 20:19:20 +00:00
|
|
|
struct mp_rect *src, struct mp_rect *dst,
|
vo_opengl: refactor shader generation (part 1)
The basic idea is to use dynamically generated shaders instead of a
single monolithic file + a ton of ifdefs. Instead of having to setup
every aspect of it separately (like compiling shaders, setting uniforms,
perfoming the actual rendering steps, the GLSL parts), we generate the
GLSL on the fly, and perform the rendering at the same time. The GLSL
is regenerated every frame, but the actual compiled OpenGL-level shaders
are cached, which makes it fast again. Almost all logic can be in a
single place.
The new code is significantly more flexible, which allows us to improve
the code clarity, performance and add more features easily.
This commit is incomplete. It drops almost all previous code, and
readds only the most important things (some of them actually buggy).
The next commit will complete it - it's separate to preserve authorship
information.
2015-03-12 20:57:54 +00:00
|
|
|
struct mp_osd_res *osd);
|
2015-01-06 16:34:29 +00:00
|
|
|
struct mp_csp_equalizer;
|
|
|
|
struct mp_csp_equalizer *gl_video_eq_ptr(struct gl_video *p);
|
|
|
|
void gl_video_eq_update(struct gl_video *p);
|
2013-03-01 20:19:20 +00:00
|
|
|
|
|
|
|
void gl_video_set_debug(struct gl_video *p, bool enable);
|
2014-10-18 16:30:22 +00:00
|
|
|
void gl_video_resize_redraw(struct gl_video *p, int w, int h);
|
2013-03-01 20:19:20 +00:00
|
|
|
|
2015-02-07 12:54:18 +00:00
|
|
|
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);
|
|
|
|
|
2014-12-09 16:47:02 +00:00
|
|
|
void gl_video_set_gl_state(struct gl_video *p);
|
|
|
|
void gl_video_unset_gl_state(struct gl_video *p);
|
2014-11-23 19:06:05 +00:00
|
|
|
void gl_video_reset(struct gl_video *p);
|
2015-02-04 22:37:38 +00:00
|
|
|
bool gl_video_showing_interpolated_frame(struct gl_video *p);
|
2014-12-09 16:47:02 +00:00
|
|
|
|
2013-11-03 23:00:18 +00:00
|
|
|
struct gl_hwdec;
|
|
|
|
void gl_video_set_hwdec(struct gl_video *p, struct gl_hwdec *hwdec);
|
2013-03-01 20:19:20 +00:00
|
|
|
|
|
|
|
#endif
|