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>
|
|
|
|
|
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];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct gl_video_opts {
|
|
|
|
char *scalers[2];
|
|
|
|
float scaler_params[2];
|
|
|
|
int indirect;
|
2014-02-26 23:53:41 +00:00
|
|
|
float gamma;
|
2013-03-01 20:19:20 +00:00
|
|
|
int srgb;
|
vo_opengl: Simplify and clarify color correction code
This commit:
- Changes some of the #define and variable names for clarification and
adds comments where appropriate.
- Unifies :srgb and :icc-profile, making them fit into the same step of
the decoding process and removing the weird interactions between both
of them.
- Makes :icc-profile take precedence over :srgb (to significantly reduce
the number of confusing and useless special cases)
- Moves BT709 decompanding (approximate or actual) to the shader in all
cases, making it happen before upscaling (instead of the old 0.45
gamma function). This is the simpler and more proper way to do it.
- Enables the approx gamma function to work with :srgb as well due to
this (since they now share the gamma expansion code).
- Renames :icc-approx-gamma to :approx-gamma since it is no longer tied
to the ICC options or LittleCMS.
- Uses gamma 2.4 as input space for the actual 3DLUT, this is now a
pretty arbitrary factor but I picked 2.4 mainly because a higher pure
power value here seems to produce visually better results with wide
gamut profiles, rather then the previous 1.95 or BT.709.
- Adds the input gamma space to the 3dlut cache header in case we change
it more in the future, or even make it user customizable (though I
don't see why the latter would really be necessary).
- Fixes the OSD's gamma when using :srgb, which was previously still
using the old (0.45) approximation in all cases.
- Updates documentation on :srgb, it was still mentioning the old
behavior from circa a year ago.
This commit should serve to both open up and make the CMS/shader code much
more accessible and less confusing/error-prone and simultaneously also
improve the performance of 3DLUTs with wide gamut color spaces.
I would liked to have made it more modular but almost all of these
changes are interdependent, save for the documentation updates.
Note: Right now, the "3DLUT takes precedence over SRGB" logic is just
coded into gl_lcms.c's compile_shaders function. Ideally, this should be
done earlier, when parsing the options (by overriding the actual
opts.srgb flag) and output a warning to the user.
Note: I'm not sure how well this works together with real-world
subtitles that may need to be color corrected as well. I'm not sure
whether :approx-gamma needs to apply to subtitles as well. I'll need to
test this on proper files later.
Note: As of now, linear light scaling is still intrinsically tied to
either :srgb or :icc-profile. It would be thinkable to have this as an
extra option, :linear-scaling or similar, that could be used with or
without the two color management options.
2014-03-05 02:56:30 +00:00
|
|
|
int approx_gamma;
|
2013-03-01 20:19:20 +00:00
|
|
|
int scale_sep;
|
|
|
|
int fancy_downscaling;
|
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;
|
|
|
|
int stereo_mode;
|
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;
|
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;
|
2013-03-01 20:19:20 +00:00
|
|
|
|
|
|
|
struct gl_video;
|
|
|
|
|
2014-06-15 18:46:57 +00:00
|
|
|
struct gl_video *gl_video_init(GL *gl, struct mp_log *log, struct osd_state *osd);
|
2013-03-01 20:19:20 +00:00
|
|
|
void gl_video_uninit(struct gl_video *p);
|
|
|
|
void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts);
|
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);
|
|
|
|
void gl_video_upload_image(struct gl_video *p, struct mp_image *img);
|
|
|
|
void gl_video_render_frame(struct gl_video *p);
|
|
|
|
struct mp_image *gl_video_download_image(struct gl_video *p);
|
|
|
|
void gl_video_resize(struct gl_video *p, struct mp_rect *window,
|
|
|
|
struct mp_rect *src, struct mp_rect *dst,
|
|
|
|
struct mp_osd_res *osd);
|
2014-03-28 23:25:08 +00:00
|
|
|
void gl_video_get_colorspace(struct gl_video *p, struct mp_image_params *params);
|
2013-03-01 20:19:20 +00:00
|
|
|
bool gl_video_set_equalizer(struct gl_video *p, const char *name, int val);
|
|
|
|
bool gl_video_get_equalizer(struct gl_video *p, const char *name, int *val);
|
|
|
|
|
|
|
|
void gl_video_set_debug(struct gl_video *p, bool enable);
|
2013-03-15 19:17:33 +00:00
|
|
|
void gl_video_resize_redraw(struct gl_video *p, int w, int h);
|
2013-03-01 20:19:20 +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
|