diff options
Diffstat (limited to 'libvo')
-rw-r--r-- | libvo/gl_common.c | 215 | ||||
-rw-r--r-- | libvo/gl_common.h | 21 | ||||
-rw-r--r-- | libvo/mga_common.c | 19 | ||||
-rw-r--r-- | libvo/vo_cvidix.c | 2 | ||||
-rw-r--r-- | libvo/vo_dfbmga.c | 4 | ||||
-rw-r--r-- | libvo/vo_dga.c | 10 | ||||
-rw-r--r-- | libvo/vo_fbdev.c | 10 | ||||
-rw-r--r-- | libvo/vo_ggi.c | 30 | ||||
-rw-r--r-- | libvo/vo_gl.c | 146 | ||||
-rw-r--r-- | libvo/vo_gl2.c | 12 | ||||
-rw-r--r-- | libvo/vo_macosx.m | 4 | ||||
-rw-r--r-- | libvo/vo_quartz.c | 4 | ||||
-rw-r--r-- | libvo/vo_svga.c | 10 | ||||
-rw-r--r-- | libvo/vo_tga.c | 2 | ||||
-rw-r--r-- | libvo/vo_vesa.c | 2 | ||||
-rw-r--r-- | libvo/vo_winvidix.c | 12 | ||||
-rw-r--r-- | libvo/vo_x11.c | 8 | ||||
-rw-r--r-- | libvo/vo_xover.c | 2 | ||||
-rw-r--r-- | libvo/vo_xvidix.c | 14 | ||||
-rw-r--r-- | libvo/vosub_vidix.c | 6 | ||||
-rw-r--r-- | libvo/x11_common.c | 12 |
21 files changed, 271 insertions, 274 deletions
diff --git a/libvo/gl_common.c b/libvo/gl_common.c index 68576504a4..9c84e71cf2 100644 --- a/libvo/gl_common.c +++ b/libvo/gl_common.c @@ -15,6 +15,7 @@ #include <math.h> #include "old_vo_defines.h" #include "gl_common.h" +#include "libavutil/common.h" /** * \defgroup glextfunctions OpenGL extension functions @@ -769,7 +770,7 @@ static const char *unsharp_filt_template = "TEX b.g, coord2.zwzw, texture[%c], %s;" "DP3 b, b, {0.25, 0.25, 0.25};" "SUB b.r, a.r, b.r;" - "MAD yuv.%c, b.r, %s, a.r;"; + "MAD yuv.%c, b.r, {%f}, a.r;"; static const char *unsharp_filt_template2 = "PARAM dcoord%c = {%f, %f, %f, %f};" @@ -793,7 +794,7 @@ static const char *unsharp_filt_template2 = "TEX b.g, coord2.zwzw, texture[%c], %s;" "DP4 b.r, b, {-0.1171875, -0.1171875, -0.1171875, -0.09765625};" "MAD b.r, a.r, {0.859375}, b.r;" - "MAD yuv.%c, b.r, %s, a.r;"; + "MAD yuv.%c, b.r, {%f}, a.r;"; static const char *yuv_prog_template = "PARAM ycoef = {%.4f, %.4f, %.4f};" @@ -867,80 +868,68 @@ static void create_scaler_textures(int scaler, int *texu, char *texs) { static void gen_gamma_map(unsigned char *map, int size, float gamma); -static void get_yuv2rgb_coeffs(float brightness, float contrast, float uvcos, float uvsin, - float *ry, float *ru, float *rv, float *rc, - float *gy, float *gu, float *gv, float *gc, - float *by, float *bu, float *bv, float *bc) { - *ry = 1.164 * contrast; - *gy = 1.164 * contrast; - *by = 1.164 * contrast; - *ru = 0 * uvcos + 1.596 * uvsin; - *rv = 0 * uvsin + 1.596 * uvcos; - *gu = -0.391 * uvcos + -0.813 * uvsin; - *gv = -0.391 * uvsin + -0.813 * uvcos; - *bu = 2.018 * uvcos + 0 * uvsin; - *bv = 2.018 * uvsin + 0 * uvcos; - *rc = (-16 * *ry + (-128) * *ru + (-128) * *rv) / 255.0 + brightness; - *gc = (-16 * *gy + (-128) * *gu + (-128) * *gv) / 255.0 + brightness; - *bc = (-16 * *by + (-128) * *bu + (-128) * *bv) / 255.0 + brightness; - // these "center" contrast control so that e.g. a contrast of 0 - // leads to a grey image, not a black one - *rc += 0.5 - contrast / 2.0; - *gc += 0.5 - contrast / 2.0; - *bc += 0.5 - contrast / 2.0; +#define ROW_R 0 +#define ROW_G 1 +#define ROW_B 2 +#define COL_Y 0 +#define COL_U 1 +#define COL_V 2 +#define COL_C 3 + +static void get_yuv2rgb_coeffs(gl_conversion_params_t *params, float yuv2rgb[3][4]) { + float uvcos = params->saturation * cos(params->hue); + float uvsin = params->saturation * sin(params->hue); + int i; + float uv_coeffs[3][2] = { + { 0.000, 1.596}, + {-0.391, -0.813}, + { 2.018, 0.000} + }; + for (i = 0; i < 3; i++) { + yuv2rgb[i][COL_C] = params->brightness; + yuv2rgb[i][COL_Y] = 1.164 * params->contrast; + yuv2rgb[i][COL_C] += (-16 / 255.0) * yuv2rgb[i][COL_Y]; + yuv2rgb[i][COL_U] = uv_coeffs[i][0] * uvcos + uv_coeffs[i][1] * uvsin; + yuv2rgb[i][COL_C] += (-128 / 255.0) * yuv2rgb[i][COL_U]; + yuv2rgb[i][COL_V] = uv_coeffs[i][0] * uvsin + uv_coeffs[i][1] * uvcos; + yuv2rgb[i][COL_C] += (-128 / 255.0) * yuv2rgb[i][COL_V]; + // this "centers" contrast control so that e.g. a contrast of 0 + // leads to a grey image, not a black one + yuv2rgb[i][COL_C] += 0.5 - params->contrast / 2.0; + } } //! size of gamma map use to avoid slow exp function in gen_yuv2rgb_map #define GMAP_SIZE (1024) /** * \brief generate a 3D YUV -> RGB map + * \param params struct containing parameters like brightness, gamma, ... * \param map where to store map. Must provide space for (size + 2)^3 elements * \param size size of the map, excluding border - * \param brightness desired brightness adjustment for conversion - * \param contrast desired contrast adjustment for conversion - * \param uvcos desired hue/saturation adjustment for conversion - * \param uvsin desired hue/saturation adjustment for conversion - * \param rgamma desired red gamma adjustment for conversion - * \param ggamma desired green gamma adjustment for conversion - * \param bgamma desired blue gamma adjustment for conversion */ -static void gen_yuv2rgb_map(unsigned char *map, int size, float brightness, - float contrast, float uvcos, float uvsin, - float rgamma, float ggamma, float bgamma) { - int i, j, k; +static void gen_yuv2rgb_map(gl_conversion_params_t *params, unsigned char *map, int size) { + int i, j, k, l; float step = 1.0 / size; float y, u, v; - float r, g, b; - float ry, ru, rv, rc; - float gy, gu, gv, gc; - float by, bu, bv, bc; + float yuv2rgb[3][4]; unsigned char gmaps[3][GMAP_SIZE]; - gen_gamma_map(gmaps[0], GMAP_SIZE, rgamma); - gen_gamma_map(gmaps[1], GMAP_SIZE, ggamma); - gen_gamma_map(gmaps[2], GMAP_SIZE, bgamma); - get_yuv2rgb_coeffs(brightness, contrast, uvcos, uvsin, - &ry, &ru, &rv, &rc, &gy, &gu, &gv, &gc, &by, &bu, &bv, &bc); - ry *= GMAP_SIZE - 1; ru *= GMAP_SIZE - 1; rv *= GMAP_SIZE - 1; rc *= GMAP_SIZE - 1; - gy *= GMAP_SIZE - 1; gu *= GMAP_SIZE - 1; gv *= GMAP_SIZE - 1; gc *= GMAP_SIZE - 1; - by *= GMAP_SIZE - 1; bu *= GMAP_SIZE - 1; bv *= GMAP_SIZE - 1; bc *= GMAP_SIZE - 1; + gen_gamma_map(gmaps[0], GMAP_SIZE, params->rgamma); + gen_gamma_map(gmaps[1], GMAP_SIZE, params->ggamma); + gen_gamma_map(gmaps[2], GMAP_SIZE, params->bgamma); + get_yuv2rgb_coeffs(params, yuv2rgb); + for (i = 0; i < 3; i++) + for (j = 0; j < 4; j++) + yuv2rgb[i][j] *= GMAP_SIZE - 1; v = 0; for (i = -1; i <= size; i++) { u = 0; for (j = -1; j <= size; j++) { y = 0; for (k = -1; k <= size; k++) { - r = ry * y + ru * u + rv * v + rc; - g = gy * y + gu * u + gv * v + gc; - b = by * y + bu * u + bv * v + bc; - if (r > GMAP_SIZE - 1) r = GMAP_SIZE - 1; - if (r < 0) r = 0; - if (g > GMAP_SIZE - 1) g = GMAP_SIZE - 1; - if (g < 0) g = 0; - if (b > GMAP_SIZE - 1) b = GMAP_SIZE - 1; - if (b < 0) b = 0; - *map++ = gmaps[0][(int)r]; - *map++ = gmaps[1][(int)g]; - *map++ = gmaps[2][(int)b]; + for (l = 0; l < 3; l++) { + float rgb = yuv2rgb[l][COL_Y] * y + yuv2rgb[l][COL_U] * u + yuv2rgb[l][COL_V] * v + yuv2rgb[l][COL_C]; + *map++ = gmaps[l][av_clip(rgb, 0, GMAP_SIZE - 1)]; + } y += (k == -1 || k == size - 1) ? step / 2 : step; } u += (j == -1 || j == size - 1) ? step / 2 : step; @@ -955,20 +944,13 @@ static void gen_yuv2rgb_map(unsigned char *map, int size, float brightness, #define LOOKUP_3DRES 32 /** * \brief creates and initializes helper textures needed for yuv conversion + * \param params struct containing parameters like brightness, gamma, ... * \param texu contains next free texture unit number * \param texs texture unit ids for the conversion are stored in this array - * \param brightness desired brightness adjustment for conversion - * \param contrast desired contrast adjustment for conversion - * \param uvcos desired hue/saturation adjustment for conversion - * \param uvsin desired hue/saturation adjustment for conversion - * \param rgamma desired red gamma adjustment for conversion - * \param ggamma desired green gamma adjustment for conversion - * \param bgamma desired blue gamma adjustment for conversion */ -static void create_conv_textures(int conv, int *texu, char *texs, - float brightness, float contrast, float uvcos, float uvsin, - float rgamma, float ggamma, float bgamma) { +static void create_conv_textures(gl_conversion_params_t *params, int *texu, char *texs) { unsigned char *lookup_data = NULL; + int conv = YUV_CONVERSION(params->type); switch (conv) { case YUV_CONVERSION_FRAGMENT: case YUV_CONVERSION_FRAGMENT_POW: @@ -977,9 +959,9 @@ static void create_conv_textures(int conv, int *texu, char *texs, texs[0] = (*texu)++; ActiveTexture(GL_TEXTURE0 + texs[0]); lookup_data = malloc(4 * LOOKUP_RES); - gen_gamma_map(lookup_data, LOOKUP_RES, rgamma); - gen_gamma_map(&lookup_data[LOOKUP_RES], LOOKUP_RES, ggamma); - gen_gamma_map(&lookup_data[2 * LOOKUP_RES], LOOKUP_RES, bgamma); + 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); glCreateClearTex(GL_TEXTURE_2D, GL_LUMINANCE8, GL_LINEAR, LOOKUP_RES, 4, 0); glUploadTex(GL_TEXTURE_2D, GL_LUMINANCE, GL_UNSIGNED_BYTE, lookup_data, @@ -997,8 +979,7 @@ static void create_conv_textures(int conv, int *texu, char *texs, texs[0] = (*texu)++; ActiveTexture(GL_TEXTURE0 + texs[0]); lookup_data = malloc(3 * sz * sz * sz); - gen_yuv2rgb_map(lookup_data, LOOKUP_3DRES, brightness, contrast, - uvcos, uvsin, rgamma, ggamma, bgamma); + gen_yuv2rgb_map(params, lookup_data, LOOKUP_3DRES); glAdjustAlignment(sz); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); TexImage3D(GL_TEXTURE_3D, 0, 3, sz, sz, sz, 1, @@ -1031,9 +1012,11 @@ static void create_conv_textures(int conv, int *texu, char *texs, * \param rect if rectangular (pixel) adressing should be used for in_tex * \param texw width of the in_tex texture * \param texh height of the in_tex texture + * \param strength strength of filter effect if the scaler does some kind of filtering */ static void add_scaler(int scaler, char **prog_pos, int *remain, char *texs, - char in_tex, char out_comp, int rect, int texw, int texh) { + char in_tex, char out_comp, int rect, int texw, int texh, + double strength) { const char *ttype = rect ? "RECT" : "2D"; const float ptw = rect ? 1.0 : 1.0 / texw; const float pth = rect ? 1.0 : 1.0 / texh; @@ -1079,7 +1062,7 @@ static void add_scaler(int scaler, char **prog_pos, int *remain, char *texs, out_comp, 0.5 * ptw, 0.5 * pth, 0.5 * ptw, -0.5 * pth, in_tex, out_comp, in_tex, out_comp, in_tex, in_tex, ttype, in_tex, ttype, in_tex, ttype, in_tex, ttype, - in_tex, ttype, out_comp, "{0.5}"); + in_tex, ttype, out_comp, strength); break; case YUV_SCALER_UNSHARP2: snprintf(*prog_pos, *remain, unsharp_filt_template2, @@ -1089,7 +1072,7 @@ static void add_scaler(int scaler, char **prog_pos, int *remain, char *texs, in_tex, ttype, in_tex, ttype, in_tex, ttype, in_tex, ttype, in_tex, ttype, in_tex, out_comp, in_tex, out_comp, in_tex, ttype, in_tex, ttype, in_tex, ttype, - in_tex, ttype, out_comp, "{0.5}"); + in_tex, ttype, out_comp, strength); break; } *remain -= strlen(*prog_pos); @@ -1156,17 +1139,14 @@ int loadGPUProgram(GLenum target, char *prog) { /** * \brief setup a fragment program that will do YUV->RGB conversion - * \param brightness brightness adjustment offset - * \param contrast contrast adjustment factor - * \param uvcos used for saturation and hue adjustment - * \param uvsin used for saturation and hue adjustment - * \param lookup use fragment program that uses texture unit 4 to - * do additional conversion via lookup. + * \param parms struct containing parameters like conversion and scaler type, + * brightness, ... */ -static void glSetupYUVFragprog(float brightness, float contrast, - float uvcos, float uvsin, float rgamma, - float ggamma, float bgamma, int type, int rect, - int texw, int texh) { +static void glSetupYUVFragprog(gl_conversion_params_t *params) { + int type = params->type; + int texw = params->texw; + int texh = params->texh; + int rect = params->target == GL_TEXTURE_RECTANGLE; static const char prog_hdr[] = "!!ARBfp1.0\n" "OPTION ARB_precision_hint_fastest;" @@ -1182,11 +1162,8 @@ static void glSetupYUVFragprog(float brightness, float contrast, GLint i; // this is the conversion matrix, with y, u, v factors // for red, green, blue and the constant offsets - float ry, ru, rv, rc; - float gy, gu, gv, gc; - float by, bu, bv, bc; - create_conv_textures(YUV_CONVERSION(type), &cur_texu, conv_texs, - brightness, contrast, uvcos, uvsin, rgamma, ggamma, bgamma); + float yuv2rgb[3][4]; + create_conv_textures(params, &cur_texu, conv_texs); create_scaler_textures(YUV_LUM_SCALER(type), &cur_texu, lum_scale_texs); if (YUV_CHROM_SCALER(type) == YUV_LUM_SCALER(type)) memcpy(chrom_scale_texs, lum_scale_texs, sizeof(chrom_scale_texs)); @@ -1206,26 +1183,34 @@ static void glSetupYUVFragprog(float brightness, float contrast, prog_pos = yuv_prog + sizeof(prog_hdr) - 1; prog_remain = MAX_PROGSZ - sizeof(prog_hdr); add_scaler(YUV_LUM_SCALER(type), &prog_pos, &prog_remain, lum_scale_texs, - '0', 'r', rect, texw, texh); + '0', 'r', rect, texw, texh, params->filter_strength); add_scaler(YUV_CHROM_SCALER(type), &prog_pos, &prog_remain, chrom_scale_texs, - '1', 'g', rect, texw / 2, texh / 2); + '1', 'g', rect, texw / 2, texh / 2, params->filter_strength); add_scaler(YUV_CHROM_SCALER(type), &prog_pos, &prog_remain, chrom_scale_texs, - '2', 'b', rect, texw / 2, texh / 2); - get_yuv2rgb_coeffs(brightness, contrast, uvcos, uvsin, - &ry, &ru, &rv, &rc, &gy, &gu, &gv, &gc, &by, &bu, &bv, &bc); + '2', 'b', rect, texw / 2, texh / 2, params->filter_strength); + get_yuv2rgb_coeffs(params, yuv2rgb); switch (YUV_CONVERSION(type)) { case YUV_CONVERSION_FRAGMENT: snprintf(prog_pos, prog_remain, yuv_prog_template, - ry, gy, by, ru, gu, bu, rv, gv, bv, rc, gc, bc); + yuv2rgb[ROW_R][COL_Y], yuv2rgb[ROW_G][COL_Y], yuv2rgb[ROW_B][COL_Y], + 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]); break; case YUV_CONVERSION_FRAGMENT_POW: snprintf(prog_pos, prog_remain, yuv_pow_prog_template, - ry, gy, by, ru, gu, bu, rv, gv, bv, rc, gc, bc, - (float)1.0 / rgamma, (float)1.0 / bgamma, (float)1.0 / bgamma); + yuv2rgb[ROW_R][COL_Y], yuv2rgb[ROW_G][COL_Y], yuv2rgb[ROW_B][COL_Y], + 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); break; case YUV_CONVERSION_FRAGMENT_LOOKUP: snprintf(prog_pos, prog_remain, yuv_lookup_prog_template, - ry, gy, by, ru, gu, bu, rv, gv, bv, rc, gc, bc, + yuv2rgb[ROW_R][COL_Y], yuv2rgb[ROW_G][COL_Y], yuv2rgb[ROW_B][COL_Y], + 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], conv_texs[0], conv_texs[0], conv_texs[0]); break; case YUV_CONVERSION_FRAGMENT_LOOKUP3D: @@ -1265,25 +1250,14 @@ static void gen_gamma_map(unsigned char *map, int size, float gamma) { /** * \brief setup YUV->RGB conversion - * \param target texture target for Y, U and V textures (e.g. GL_TEXTURE_2D) - * \param type YUV conversion type - * \param brightness brightness adjustment offset - * \param contrast contrast adjustment factor - * \param hue hue adjustment angle - * \param saturation saturation adjustment factor - * \param rgamma gamma value for red channel - * \param ggamma gamma value for green channel - * \param bgamma gamma value for blue channel + * \param parms struct containing parameters like conversion and scaler type, + * brightness, ... * \ingroup glconversion */ -void glSetupYUVConversion(GLenum target, int type, - float brightness, float contrast, - float hue, float saturation, - float rgamma, float ggamma, float bgamma, - int texw, int texh) { - float uvcos = saturation * cos(hue); - float uvsin = saturation * sin(hue); - switch (YUV_CONVERSION(type)) { +void glSetupYUVConversion(gl_conversion_params_t *params) { + float uvcos = params->saturation * cos(params->hue); + float uvsin = params->saturation * sin(params->hue); + switch (YUV_CONVERSION(params->type)) { case YUV_CONVERSION_COMBINERS: glSetupYUVCombiners(uvcos, uvsin); break; @@ -1294,13 +1268,10 @@ void glSetupYUVConversion(GLenum target, int type, case YUV_CONVERSION_FRAGMENT_LOOKUP3D: case YUV_CONVERSION_FRAGMENT: case YUV_CONVERSION_FRAGMENT_POW: - glSetupYUVFragprog(brightness, contrast, uvcos, uvsin, - rgamma, ggamma, bgamma, type, - target == GL_TEXTURE_RECTANGLE, - texw, texh); + glSetupYUVFragprog(params); break; default: - mp_msg(MSGT_VO, MSGL_ERR, "[gl] unknown conversion type %i\n", YUV_CONVERSION(type)); + mp_msg(MSGT_VO, MSGL_ERR, "[gl] unknown conversion type %i\n", YUV_CONVERSION(params->type)); } } diff --git a/libvo/gl_common.h b/libvo/gl_common.h index 05d1bde862..a7a4f8c2b1 100644 --- a/libvo/gl_common.h +++ b/libvo/gl_common.h @@ -263,11 +263,22 @@ 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) /** \} */ -void glSetupYUVConversion(GLenum target, int type, - float brightness, float contrast, - float hue, float saturation, - float rgamma, float ggamma, float bgamma, - int texw, int texh); +typedef struct { + GLenum target; + int type; + float brightness; + float contrast; + float hue; + float saturation; + float rgamma; + float ggamma; + float bgamma; + int texw; + int texh; + float filter_strength; +} gl_conversion_params_t; + +void glSetupYUVConversion(gl_conversion_params_t *params); void glEnableYUVConversion(GLenum target, int type); void glDisableYUVConversion(GLenum target, int type); diff --git a/libvo/mga_common.c b/libvo/mga_common.c index e90aebd764..acd7d88cd2 100644 --- a/libvo/mga_common.c +++ b/libvo/mga_common.c @@ -364,7 +364,7 @@ static int mga_init(int width,int height,unsigned int format){ mga_vid_config.format=MGA_VID_FORMAT_UYVY; break; default: mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_MGA_InvalidOutputFormat,format); - return (-1); + return -1; } mga_vid_config.src_width = width; @@ -382,7 +382,7 @@ static int mga_init(int width,int height,unsigned int format){ if(width > 1024 && height > 1024) { mp_msg(MSGT_VO,MSGL_ERR, MGSTR_LIBVO_MGA_ResolutionTooHigh); - return (-1); + return -1; } else if(height <= 1024) { // try whether we have a G550 @@ -393,7 +393,7 @@ static int mga_init(int width,int height,unsigned int format){ { // we don't have a G550, so our resolution is too high mp_msg(MSGT_VO,MSGL_ERR, MGSTR_LIBVO_MGA_ResolutionTooHigh); - return (-1); + return -1; } else { // there is a deeper problem // we have a G550, but still couldn't configure mga_vid @@ -445,6 +445,7 @@ static int mga_uninit(){ static int preinit(const char *vo_subdevice) { + uint32_t ver; const char *devname=vo_subdevice?vo_subdevice:"/dev/mga_vid"; sws_rgb2rgb_init(get_sws_cpuflags()); @@ -453,7 +454,17 @@ static int preinit(const char *vo_subdevice) { perror("open"); mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_MGA_CouldntOpen,devname); - return(-1); + return -1; + } + + // check whether the mga_vid driver has the same + // version as we expect + + ioctl(f,MGA_VID_GET_VERSION,&ver); + if(MGA_VID_VERSION != ver) + { + mp_msg(MSGT_VO, MSGL_ERR, MGSTR_LIBVO_MGA_mgavidVersionMismatch, ver, MGA_VID_VERSION); + return -1; } #ifdef VO_XMGA diff --git a/libvo/vo_cvidix.c b/libvo/vo_cvidix.c index f68ae611bd..669b922a6d 100644 --- a/libvo/vo_cvidix.c +++ b/libvo/vo_cvidix.c @@ -134,7 +134,7 @@ static int draw_frame(uint8_t *src[]){ } static int query_format(uint32_t format){ - return(vidix_query_fourcc(format)); + return vidix_query_fourcc(format); } static void uninit(void){ diff --git a/libvo/vo_dfbmga.c b/libvo/vo_dfbmga.c index d829dc219a..fac15a46dd 100644 --- a/libvo/vo_dfbmga.c +++ b/libvo/vo_dfbmga.c @@ -917,11 +917,11 @@ query_format( uint32_t format ) return 0; } - return (VFCAP_HWSCALE_UP | + return VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_CSP_SUPPORTED | - VFCAP_OSD); + VFCAP_OSD; } static void diff --git a/libvo/vo_dga.c b/libvo/vo_dga.c index 70079440b6..1aa0050337 100644 --- a/libvo/vo_dga.c +++ b/libvo/vo_dga.c @@ -119,11 +119,11 @@ static int vd_EnableMode(int depth, int bitspp, static int vd_ModeEqual(int depth, int bitspp, int rmask, int gmask, int bmask, int index) { - return ((vo_dga_modes[index].vdm_depth == depth && + return (vo_dga_modes[index].vdm_depth == depth && vo_dga_modes[index].vdm_bitspp == bitspp && vo_dga_modes[index].vdm_rmask == rmask && vo_dga_modes[index].vdm_gmask == gmask && - vo_dga_modes[index].vdm_bmask == bmask) ? 1 : 0); + vo_dga_modes[index].vdm_bmask == bmask) ? 1 : 0; } @@ -964,7 +964,7 @@ static uint32_t get_image(mp_image_t * mpi) || (mpi->type == MP_IMGTYPE_STATIC && vo_dga_nr_video_buffers > 1) || (mpi->type == MP_IMGTYPE_IP && vo_dga_nr_video_buffers < 2) || (mpi->type == MP_IMGTYPE_IPB)) - return (VO_FALSE); + return VO_FALSE; if ((mpi->flags & MP_IMGFLAG_ACCEPT_STRIDE) || (mpi->flags & MP_IMGFLAG_ACCEPT_WIDTH && @@ -978,10 +978,10 @@ static uint32_t get_image(mp_image_t * mpi) mpi->width = (vo_dga_bytes_per_line + vo_dga_vp_skip) / (mpi->bpp / 8); mpi->flags |= MP_IMGFLAG_DIRECT; - return (VO_TRUE); + return VO_TRUE; } - return (VO_FALSE); + return VO_FALSE; } static int control(uint32_t request, void *data) diff --git a/libvo/vo_fbdev.c b/libvo/vo_fbdev.c index 178f17869a..abe5d9aeeb 100644 --- a/libvo/vo_fbdev.c +++ b/libvo/vo_fbdev.c @@ -1038,7 +1038,7 @@ static int query_format(uint32_t format) return 0; #ifdef CONFIG_VIDIX if(vidix_name) - return (vidix_query_fourcc(format)); + return vidix_query_fourcc(format); #endif if ((format & IMGFMT_BGR_MASK) == IMGFMT_BGR) { int bpp = format & 0xff; @@ -1141,8 +1141,8 @@ static int preinit(const char *vo_subdevice) fb_dev_name = strdup(vo_subdevice); } } - if(!pre_init_err) return (pre_init_err=(fb_preinit(0)?0:-1)); - return(-1); + if(!pre_init_err) return pre_init_err = (fb_preinit(0) ? 0 : -1); + return -1; } static uint32_t get_image(mp_image_t *mpi) @@ -1156,12 +1156,12 @@ static uint32_t get_image(mp_image_t *mpi) (mpi->width != in_width) || (mpi->height != in_height) ) - return(VO_FALSE); + return VO_FALSE; mpi->planes[0] = center; mpi->stride[0] = fb_line_len; mpi->flags |= MP_IMGFLAG_DIRECT; - return(VO_TRUE); + return VO_TRUE; } static int control(uint32_t request, void *data) diff --git a/libvo/vo_ggi.c b/libvo/vo_ggi.c index a4ded390a6..b3f970ad8c 100644 --- a/libvo/vo_ggi.c +++ b/libvo/vo_ggi.c @@ -143,17 +143,17 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, if (ggiSetMode(ggi_conf.vis, &mode) < 0) { mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to set display mode\n"); - return (-1); + return -1; } if (ggiGetMode(ggi_conf.vis, &mode) < 0) { mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to get display mode\n"); - return (-1); + return -1; } if ((mode.graphtype == GT_INVALID) || (mode.graphtype == GT_AUTO)) { mp_msg(MSGT_VO, MSGL_ERR, "[ggi] not supported depth/bpp\n"); - return (-1); + return -1; } #if 0 @@ -223,7 +223,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, } else { mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] Unknown image format: %s\n", vo_format_name(ggi_conf.srcformat)); - return (-1); + return -1; } mp_msg(MSGT_VO, MSGL_INFO, "[ggi] input: %dx%dx%d, output: %dx%dx%d\n", @@ -237,7 +237,7 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, ggi_conf.flushregion.x2 = vo_dwidth; ggi_conf.flushregion.y2 = vo_dheight; - return (0); + return 0; } static uint32_t get_image(mp_image_t *mpi) @@ -246,19 +246,19 @@ static uint32_t get_image(mp_image_t *mpi) if (!((IMGFMT_IS_BGR(mpi->imgfmt)) && (IMGFMT_BGR_DEPTH(mpi->imgfmt) == vo_dbpp))) { - return (VO_FALSE); + return VO_FALSE; } if (!((IMGFMT_IS_RGB(mpi->imgfmt)) && (IMGFMT_RGB_DEPTH(mpi->imgfmt) == vo_dbpp))) { - return (VO_FALSE); + return VO_FALSE; } if (!((mpi->width == ggi_conf.srcwidth) && (mpi->height == ggi_conf.srcheight))) { - return (VO_FALSE); + return VO_FALSE; } mpi->planes[1] = mpi->planes[2] = NULL; @@ -274,7 +274,7 @@ static uint32_t get_image(mp_image_t *mpi) } #endif - return (VO_TRUE); + return VO_TRUE; } @@ -288,7 +288,7 @@ static int draw_frame(uint8_t *src[]) ggi_conf.flushregion.x2 = vo_dwidth; ggi_conf.flushregion.y2 = vo_dheight; - return (0); + return 0; } static void draw_osd(void) @@ -348,7 +348,7 @@ static int draw_slice(uint8_t *src[], int stride[], ggi_conf.flushregion.y2 = vo_dy + y + h; } - return (1); + return 1; } static int query_format(uint32_t format) @@ -388,19 +388,19 @@ static int query_format(uint32_t format) return vfcap; } } - return (0); + return 0; } static int preinit(const char *arg) { if (ggiInit() != 0) { mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] unable to initialize GGI\n"); - return (-1); + return -1; } #ifdef HAVE_GGIWMH if (ggiWmhInit() < 0) { mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] unable to initialize libggiwmh\n"); - return (-1); + return -1; } #endif @@ -421,7 +421,7 @@ static int preinit(const char *arg) mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] unable to open '%s' output\n", (ggi_conf.driver == NULL) ? "default" : ggi_conf.driver); ggiExit(); - return (-1); + return -1; } ggi_conf.drawvis = ggi_conf.vis; diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c index 93dfa6f923..68345ef2cc 100644 --- a/libvo/vo_gl.c +++ b/libvo/vo_gl.c @@ -74,6 +74,7 @@ static int use_aspect; static int use_yuv; static int lscale; static int cscale; +static float filter_strength; static int yuvconvtype; static int use_rectangle; static int err_shown; @@ -116,6 +117,8 @@ static int ass_border_x, ass_border_y; static unsigned int slice_height = 1; +static void redraw(void); + static void resize(int x,int y){ mp_msg(MSGT_VO, MSGL_V, "[gl] Resize: %dx%d\n",x,y); if (WinID >= 0) { @@ -153,7 +156,7 @@ static void resize(int x,int y){ vo_osd_changed(OSDTYPE_OSD); } glClear(GL_COLOR_BUFFER_BIT); - flip_page(); + redraw(); } static void texSize(int w, int h, int *texw, int *texh) { @@ -179,9 +182,10 @@ static void update_yuvconv(void) { float rgamma = exp(log(8.0) * eq_rgamma / 100.0); float ggamma = exp(log(8.0) * eq_ggamma / 100.0); float bgamma = exp(log(8.0) * eq_bgamma / 100.0); - glSetupYUVConversion(gl_target, yuvconvtype, bri, cont, hue, sat, - rgamma, ggamma, bgamma, - texture_width, texture_height); + gl_conversion_params_t params = {gl_target, yuvconvtype, + bri, cont, hue, sat, rgamma, ggamma, bgamma, + texture_width, texture_height, filter_strength}; + glSetupYUVConversion(¶ms); if (custom_prog) { FILE *f = fopen(custom_prog, "r"); if (!f) @@ -503,7 +507,7 @@ static void check_events(void) { int e=vo_check_events(); if(e&VO_EVENT_RESIZE) resize(vo_dwidth,vo_dheight); - if(e&VO_EVENT_EXPOSE && int_pause) flip_page(); + if(e&VO_EVENT_EXPOSE && int_pause) redraw(); } /** @@ -575,6 +579,8 @@ static void create_osd_texture(int x0, int y0, int w, int h, osdtexCnt++; } +static void do_render_osd(void); + static void draw_osd(void) { if (!use_osd) return; @@ -585,11 +591,10 @@ static void draw_osd(void) osd_h = (scaled_osd) ? image_height : vo_dheight; vo_draw_text(osd_w, osd_h, create_osd_texture); } + if (vo_doublebuffering) do_render_osd(); } -static void -flip_page(void) -{ +static void do_render(void) { // glEnable(GL_TEXTURE_2D); // glBindTexture(GL_TEXTURE_2D, texture_id); @@ -603,7 +608,9 @@ flip_page(void) mpi_flipped ^ vo_flipped); if (image_format == IMGFMT_YV12) glDisableYUVConversion(gl_target, yuvconvtype); +} +static void do_render_osd(void) { if (osdtexCnt > 0 || eosdDispList) { // set special rendering parameters if (!scaled_osd) { @@ -633,16 +640,25 @@ flip_page(void) glPopMatrix(); BindTexture(gl_target, 0); } +} - if (use_glFinish) - glFinish(); - if (vo_doublebuffering) +static void flip_page(void) { + if (vo_doublebuffering) { + if (use_glFinish) glFinish(); swapGlBuffers(); - else if (!use_glFinish) - glFlush(); - - if (vo_fs && use_aspect && vo_doublebuffering) - glClear(GL_COLOR_BUFFER_BIT); + if (vo_fs && use_aspect) + glClear(GL_COLOR_BUFFER_BIT); + } else { + do_render(); + do_render_osd(); + if (use_glFinish) glFinish(); + else glFlush(); + } +} + +static void redraw(void) { + if (vo_doublebuffering) { do_render(); do_render_osd(); } + flip_page(); } //static inline uint32_t draw_slice_x11(uint8_t |