summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2009-12-31 18:07:37 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2009-12-31 18:07:37 +0000
commitc4c806a9d743ec917450515db15b270981930259 (patch)
treee21bb720e33029b0ecfe0dbe27513fd804bb3147 /libvo
parent8fb7d45abd13b0d8a427f44f19e338d8b4fb9cc0 (diff)
downloadmpv-c4c806a9d743ec917450515db15b270981930259.tar.bz2
mpv-c4c806a9d743ec917450515db15b270981930259.tar.xz
Put the colourspace-related variables into a separate struct to ease
extracting the code and sharing with other vos. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30149 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r--libvo/gl_common.c20
-rw-r--r--libvo/gl_common.h11
-rw-r--r--libvo/vo_gl.c2
-rw-r--r--libvo/vo_gl2.c2
4 files changed, 20 insertions, 15 deletions
diff --git a/libvo/gl_common.c b/libvo/gl_common.c
index 9bce6634f0..0b63cc6390 100644
--- a/libvo/gl_common.c
+++ b/libvo/gl_common.c
@@ -1018,7 +1018,7 @@ static void gen_gamma_map(unsigned char *map, int size, float gamma);
#define COL_V 2
#define COL_C 3
-static void get_yuv2rgb_coeffs(gl_conversion_params_t *params, float yuv2rgb[3][4]) {
+static void get_yuv2rgb_coeffs(struct mp_csp_params *params, float yuv2rgb[3][4]) {
float uvcos = params->saturation * cos(params->hue);
float uvsin = params->saturation * sin(params->hue);
int i;
@@ -1049,7 +1049,7 @@ static void get_yuv2rgb_coeffs(gl_conversion_params_t *params, float yuv2rgb[3][
* \param map where to store map. Must provide space for (size + 2)^3 elements
* \param size size of the map, excluding border
*/
-static void gen_yuv2rgb_map(gl_conversion_params_t *params, unsigned char *map, int size) {
+static void gen_yuv2rgb_map(struct mp_csp_params *params, unsigned char *map, int size) {
int i, j, k, l;
float step = 1.0 / size;
float y, u, v;
@@ -1101,9 +1101,9 @@ static void create_conv_textures(gl_conversion_params_t *params, int *texu, char
texs[0] = (*texu)++;
ActiveTexture(GL_TEXTURE0 + texs[0]);
lookup_data = malloc(4 * LOOKUP_RES);
- gen_gamma_map(lookup_data, LOOKUP_RES, params->rgamma);
- gen_gamma_map(&lookup_data[LOOKUP_RES], LOOKUP_RES, params->ggamma);
- gen_gamma_map(&lookup_data[2 * LOOKUP_RES], LOOKUP_RES, params->bgamma);
+ gen_gamma_map(lookup_data, LOOKUP_RES, params->csp_params.rgamma);
+ gen_gamma_map(&lookup_data[LOOKUP_RES], LOOKUP_RES, params->csp_params.ggamma);
+ gen_gamma_map(&lookup_data[2 * LOOKUP_RES], LOOKUP_RES, params->csp_params.bgamma);
glCreateClearTex(GL_TEXTURE_2D, GL_LUMINANCE8, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_LINEAR,
LOOKUP_RES, 4, 0);
glUploadTex(GL_TEXTURE_2D, GL_LUMINANCE, GL_UNSIGNED_BYTE, lookup_data,
@@ -1121,7 +1121,7 @@ static void create_conv_textures(gl_conversion_params_t *params, int *texu, char
texs[0] = (*texu)++;
ActiveTexture(GL_TEXTURE0 + texs[0]);
lookup_data = malloc(3 * sz * sz * sz);
- gen_yuv2rgb_map(params, lookup_data, LOOKUP_3DRES);
+ gen_yuv2rgb_map(&params->csp_params, lookup_data, LOOKUP_3DRES);
glAdjustAlignment(sz);
PixelStorei(GL_UNPACK_ROW_LENGTH, 0);
TexImage3D(GL_TEXTURE_3D, 0, 3, sz, sz, sz, 1,
@@ -1330,7 +1330,7 @@ static void glSetupYUVFragprog(gl_conversion_params_t *params) {
'1', 'g', rect, params->chrom_texw, params->chrom_texh, params->filter_strength);
add_scaler(YUV_CHROM_SCALER(type), &prog_pos, &prog_remain, chrom_scale_texs,
'2', 'b', rect, params->chrom_texw, params->chrom_texh, params->filter_strength);
- get_yuv2rgb_coeffs(params, yuv2rgb);
+ get_yuv2rgb_coeffs(&params->csp_params, yuv2rgb);
switch (YUV_CONVERSION(type)) {
case YUV_CONVERSION_FRAGMENT:
snprintf(prog_pos, prog_remain, yuv_prog_template,
@@ -1345,7 +1345,7 @@ static void glSetupYUVFragprog(gl_conversion_params_t *params) {
yuv2rgb[ROW_R][COL_U], yuv2rgb[ROW_G][COL_U], yuv2rgb[ROW_B][COL_U],
yuv2rgb[ROW_R][COL_V], yuv2rgb[ROW_G][COL_V], yuv2rgb[ROW_B][COL_V],
yuv2rgb[ROW_R][COL_C], yuv2rgb[ROW_G][COL_C], yuv2rgb[ROW_B][COL_C],
- (float)1.0 / params->rgamma, (float)1.0 / params->bgamma, (float)1.0 / params->bgamma);
+ (float)1.0 / params->csp_params.rgamma, (float)1.0 / params->csp_params.bgamma, (float)1.0 / params->csp_params.bgamma);
break;
case YUV_CONVERSION_FRAGMENT_LOOKUP:
snprintf(prog_pos, prog_remain, yuv_lookup_prog_template,
@@ -1397,8 +1397,8 @@ static void gen_gamma_map(unsigned char *map, int size, float gamma) {
* \ingroup glconversion
*/
void glSetupYUVConversion(gl_conversion_params_t *params) {
- float uvcos = params->saturation * cos(params->hue);
- float uvsin = params->saturation * sin(params->hue);
+ float uvcos = params->csp_params.saturation * cos(params->csp_params.hue);
+ float uvsin = params->csp_params.saturation * sin(params->csp_params.hue);
switch (YUV_CONVERSION(params->type)) {
case YUV_CONVERSION_COMBINERS:
glSetupYUVCombiners(uvcos, uvsin);
diff --git a/libvo/gl_common.h b/libvo/gl_common.h
index 23a78c24a0..8410c4c954 100644
--- a/libvo/gl_common.h
+++ b/libvo/gl_common.h
@@ -327,9 +327,8 @@ int loadGPUProgram(GLenum target, char *prog);
//! extract chrominance scaler out of type
#define YUV_CHROM_SCALER(t) ((t >> YUV_CHROM_SCALER_SHIFT) & YUV_SCALER_MASK)
/** \} */
-typedef struct {
- GLenum target;
- int type;
+
+struct mp_csp_params {
float brightness;
float contrast;
float hue;
@@ -337,6 +336,12 @@ typedef struct {
float rgamma;
float ggamma;
float bgamma;
+};
+
+typedef struct {
+ GLenum target;
+ int type;
+ struct mp_csp_params csp_params;
int texw;
int texh;
int chrom_texw;
diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c
index 058cfb614f..53ddbad977 100644
--- a/libvo/vo_gl.c
+++ b/libvo/vo_gl.c
@@ -216,7 +216,7 @@ static void update_yuvconv(void) {
float ggamma = exp(log(8.0) * eq_ggamma / 100.0);
float bgamma = exp(log(8.0) * eq_bgamma / 100.0);
gl_conversion_params_t params = {gl_target, yuvconvtype,
- bri, cont, hue, sat, rgamma, ggamma, bgamma,
+ {bri, cont, hue, sat, rgamma, ggamma, bgamma},
texture_width, texture_height, 0, 0, filter_strength};
mp_get_chroma_shift(image_format, &xs, &ys);
params.chrom_texw = params.texw >> xs;
diff --git a/libvo/vo_gl2.c b/libvo/vo_gl2.c
index fc28fe3a67..bbf850b827 100644
--- a/libvo/vo_gl2.c
+++ b/libvo/vo_gl2.c
@@ -571,7 +571,7 @@ static int initGl(uint32_t d_width, uint32_t d_height)
if (is_yuv) {
int xs, ys;
gl_conversion_params_t params = {GL_TEXTURE_2D, use_yuv,
- 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0,
+ {0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0},
texture_width, texture_height, 0, 0, 0};
switch (use_yuv) {
case YUV_CONVERSION_FRAGMENT_LOOKUP: