mirror of
https://github.com/mpv-player/mpv
synced 2024-12-23 23:32:26 +00:00
58a7d81dc5
Use a different algorithm to generate the dithering matrix. This looks much better than the previous ordered dither matrix with its cross-hatch artifacts. The matrix generation algorithm as well as its implementation was contributed by Wessel Dankers aka Fruit. The code in dither.c is his implementation, reformatted and with static global variables removed by me. The new matrix is uploaded as float texture - before this commit, it was a normal integer fixed point matrix. This means dithering will be disabled on systems without float textures. The size of the dithering matrix can be configured, as the matrix is generated at runtime. The generation of the matrix can take rather long, and is already unacceptable with size 8. The default is at 6, which takes about 100 ms on a Core2 Duo system with dither.c compiled at -O2, which I consider just about acceptable. The old ordered dithering is still available and can be selected by putting the dither=ordered sub-option. The ordered dither matrix generation code was moved to dither.c. This function was originally written by Uoti Urpala.
78 lines
2.5 KiB
C
78 lines
2.5 KiB
C
/*
|
|
* 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>
|
|
|
|
#include "sub/sub.h"
|
|
#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;
|
|
int gamma;
|
|
int srgb;
|
|
int scale_sep;
|
|
int fancy_downscaling;
|
|
int scaler_resizes_only;
|
|
int npot;
|
|
int pbo;
|
|
int dither_depth;
|
|
int dither_algo;
|
|
int dither_size;
|
|
int temporal_dither;
|
|
int fbo_format;
|
|
int stereo_mode;
|
|
int enable_alpha;
|
|
};
|
|
|
|
extern const struct m_sub_options gl_video_conf;
|
|
|
|
struct gl_video;
|
|
|
|
struct gl_video *gl_video_init(GL *gl);
|
|
void gl_video_uninit(struct gl_video *p);
|
|
void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts);
|
|
void gl_video_config(struct gl_video *p, int format, int w, int h, int dw, int dh);
|
|
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_draw_osd(struct gl_video *p, struct osd_state *osd);
|
|
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);
|
|
bool gl_video_get_csp_override(struct gl_video *p, struct mp_csp_details *csp);
|
|
bool gl_video_set_csp_override(struct gl_video *p, struct mp_csp_details *csp);
|
|
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);
|
|
void gl_video_resize_redraw(struct gl_video *p, int w, int h);
|
|
|
|
bool gl_video_check_format(int mp_format);
|
|
|
|
#endif
|