From a52ca8a2b075388dc7dd5012e4e3f4871e26b133 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 6 Jan 2015 15:04:29 +0100 Subject: [PATCH] csputils: get rid of mp_csp_details It used to be central, but now it's just unneeded. --- sub/draw_bmp.c | 6 +++--- sub/draw_bmp.h | 1 - sub/sd_ass.c | 8 ++++---- video/csputils.c | 12 ++++++------ video/csputils.h | 15 +++++---------- video/out/gl_video.c | 11 ++++------- video/out/vo_direct3d.c | 6 +++--- video/out/vo_opengl_old.c | 9 +++++---- video/sws_utils.h | 1 - video/vdpau_mixer.c | 6 +++--- 10 files changed, 33 insertions(+), 42 deletions(-) diff --git a/sub/draw_bmp.c b/sub/draw_bmp.c index 041e0a70e0..dfbdb340b2 100644 --- a/sub/draw_bmp.c +++ b/sub/draw_bmp.c @@ -289,9 +289,9 @@ static void draw_ass(struct mp_draw_sub_cache *cache, struct mp_rect bb, struct mp_image *temp, int bits, struct sub_bitmaps *sbs) { struct mp_csp_params cspar = MP_CSP_PARAMS_DEFAULTS; - cspar.colorspace.format = temp->params.colorspace; - cspar.colorspace.levels_in = temp->params.colorlevels; - cspar.colorspace.levels_out = MP_CSP_LEVELS_PC; // RGB (libass.color) + cspar.colorspace = temp->params.colorspace; + cspar.levels_in = temp->params.colorlevels; + cspar.levels_out = MP_CSP_LEVELS_PC; // RGB (libass.color) cspar.int_bits_in = bits; cspar.int_bits_out = 8; diff --git a/sub/draw_bmp.h b/sub/draw_bmp.h index 9ccd764d5d..11fbd0daa0 100644 --- a/sub/draw_bmp.h +++ b/sub/draw_bmp.h @@ -5,7 +5,6 @@ struct mp_image; struct sub_bitmaps; -struct mp_csp_details; struct mp_draw_sub_cache; void mp_draw_sub_bitmaps(struct mp_draw_sub_cache **cache, struct mp_image *dst, struct sub_bitmaps *sbs); diff --git a/sub/sd_ass.c b/sub/sd_ass.c index 733f0ffa1d..8f5b02c842 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -396,8 +396,8 @@ static void mangle_colors(struct sd *sd, struct sub_bitmaps *parts) // Conversion that VSFilter would use struct mp_csp_params vs_params = MP_CSP_PARAMS_DEFAULTS; - vs_params.colorspace.format = csp; - vs_params.colorspace.levels_in = levels; + vs_params.colorspace = csp; + vs_params.levels_in = levels; vs_params.int_bits_in = 8; vs_params.int_bits_out = 8; float vs_yuv2rgb[3][4], vs_rgb2yuv[3][4]; @@ -406,8 +406,8 @@ static void mangle_colors(struct sd *sd, struct sub_bitmaps *parts) // Proper conversion to RGB struct mp_csp_params rgb_params = MP_CSP_PARAMS_DEFAULTS; - rgb_params.colorspace.format = params.colorspace; - rgb_params.colorspace.levels_in = params.colorlevels; + rgb_params.colorspace = params.colorspace; + rgb_params.levels_in = params.colorlevels; rgb_params.int_bits_in = 8; rgb_params.int_bits_out = 8; float vs2rgb[3][4]; diff --git a/video/csputils.c b/video/csputils.c index ab49d30247..db206330bd 100644 --- a/video/csputils.c +++ b/video/csputils.c @@ -525,14 +525,14 @@ static void luma_coeffs(float m[3][4], float lr, float lg, float lb) // get the coefficients of the yuv -> rgb conversion matrix void mp_get_yuv2rgb_coeffs(struct mp_csp_params *params, float m[3][4]) { - int format = params->colorspace.format; - if (format <= MP_CSP_AUTO || format >= MP_CSP_COUNT) - format = MP_CSP_BT_601; - int levels_in = params->colorspace.levels_in; + int colorspace = params->colorspace; + if (colorspace <= MP_CSP_AUTO || colorspace >= MP_CSP_COUNT) + colorspace = MP_CSP_BT_601; + int levels_in = params->levels_in; if (levels_in <= MP_CSP_LEVELS_AUTO || levels_in >= MP_CSP_LEVELS_COUNT) levels_in = MP_CSP_LEVELS_TV; - switch (format) { + switch (colorspace) { case MP_CSP_BT_601: luma_coeffs(m, 0.299, 0.587, 0.114 ); break; case MP_CSP_BT_709: luma_coeffs(m, 0.2126, 0.7152, 0.0722); break; case MP_CSP_SMPTE_240M: luma_coeffs(m, 0.2122, 0.7013, 0.0865); break; @@ -601,7 +601,7 @@ void mp_get_yuv2rgb_coeffs(struct mp_csp_params *params, float m[3][4]) abort(); } - int levels_out = params->colorspace.levels_out; + int levels_out = params->levels_out; if (levels_out <= MP_CSP_LEVELS_AUTO || levels_out >= MP_CSP_LEVELS_COUNT) levels_out = MP_CSP_LEVELS_PC; struct rgblevels { double min, max; } diff --git a/video/csputils.h b/video/csputils.h index 1ad88bf261..4e2fe611b3 100644 --- a/video/csputils.h +++ b/video/csputils.h @@ -106,17 +106,10 @@ extern const char *const mp_stereo3d_names[MP_STEREO3D_COUNT]; #define MP_STEREO3D_NAME_DEF(x, def) \ (MP_STEREO3D_NAME(x) ? MP_STEREO3D_NAME(x) : (def)) -struct mp_csp_details { - enum mp_csp format; +struct mp_csp_params { + enum mp_csp colorspace; enum mp_csp_levels levels_in; // encoded video enum mp_csp_levels levels_out; // output device -}; - -// initializer for struct mp_csp_details that contains reasonable defaults -#define MP_CSP_DETAILS_DEFAULTS {MP_CSP_BT_601, MP_CSP_LEVELS_TV, MP_CSP_LEVELS_PC} - -struct mp_csp_params { - struct mp_csp_details colorspace; float brightness; float contrast; float hue; @@ -133,7 +126,9 @@ struct mp_csp_params { }; #define MP_CSP_PARAMS_DEFAULTS { \ - .colorspace = MP_CSP_DETAILS_DEFAULTS, \ + .colorspace = MP_CSP_BT_601, \ + .levels_in = MP_CSP_LEVELS_TV, \ + .levels_out = MP_CSP_LEVELS_PC, \ .brightness = 0, .contrast = 1, .hue = 0, .saturation = 1, \ .rgamma = 1, .ggamma = 1, .bgamma = 1, \ .texture_bits = 8, .input_bits = 8} diff --git a/video/out/gl_video.c b/video/out/gl_video.c index 24a7a13f1d..1ff0d9d333 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -638,19 +638,16 @@ static void update_uniforms(struct gl_video *p, GLuint program) gl->UseProgram(program); - struct mp_csp_details csp = MP_CSP_DETAILS_DEFAULTS; - csp.levels_in = p->image_params.colorlevels; - csp.levels_out = p->image_params.outputlevels; - csp.format = p->image_params.colorspace; - struct mp_csp_params cparams = { - .colorspace = csp, + .colorspace = p->image_params.colorspace, + .levels_in = p->image_params.colorlevels, + .levels_out = p->image_params.outputlevels, .input_bits = p->plane_bits, .texture_bits = (p->plane_bits + 7) & ~7, }; mp_csp_copy_equalizer_values(&cparams, &p->video_eq); if (p->image_desc.flags & MP_IMGFLAG_XYZ) { - cparams.colorspace.format = MP_CSP_XYZ; + cparams.colorspace = MP_CSP_XYZ; cparams.input_bits = 8; cparams.texture_bits = 8; } diff --git a/video/out/vo_direct3d.c b/video/out/vo_direct3d.c index 52ec690cf3..4a2c86aab7 100644 --- a/video/out/vo_direct3d.c +++ b/video/out/vo_direct3d.c @@ -1152,9 +1152,9 @@ static void update_colorspace(d3d_priv *priv) { float coeff[3][4]; struct mp_csp_params csp = MP_CSP_PARAMS_DEFAULTS; - csp.colorspace.format = priv->params.colorspace; - csp.colorspace.levels_in = priv->params.colorlevels; - csp.colorspace.levels_out = priv->params.outputlevels; + csp.colorspace = priv->params.colorspace; + csp.levels_in = priv->params.colorlevels; + csp.levels_out = priv->params.outputlevels; mp_csp_copy_equalizer_values(&csp, &priv->video_eq); if (priv->use_shaders) { diff --git a/video/out/vo_opengl_old.c b/video/out/vo_opengl_old.c index dc105baaaa..b88b36e5d1 100644 --- a/video/out/vo_opengl_old.c +++ b/video/out/vo_opengl_old.c @@ -1346,10 +1346,11 @@ static void update_yuvconv(struct vo *vo) if (!vo->params) return; - struct mp_csp_params cparams = { .colorspace = MP_CSP_DETAILS_DEFAULTS }; - cparams.colorspace.format = vo->params->colorspace; - cparams.colorspace.levels_in = vo->params->colorlevels; - cparams.colorspace.levels_out = vo->params->outputlevels; + struct mp_csp_params cparams = { + .colorspace = vo->params->colorspace, + .levels_in = vo->params->colorlevels, + .levels_out = vo->params->outputlevels, + }; mp_csp_copy_equalizer_values(&cparams, &p->video_eq); gl_conversion_params_t params = { p->target, p->yuvconvtype, cparams, diff --git a/video/sws_utils.h b/video/sws_utils.h index 212e1405b4..cf9aa827b2 100644 --- a/video/sws_utils.h +++ b/video/sws_utils.h @@ -6,7 +6,6 @@ #include "mp_image.h" struct mp_image; -struct mp_csp_details; struct sws_opts; // libswscale currently requires 16 bytes alignment for row pointers and diff --git a/video/vdpau_mixer.c b/video/vdpau_mixer.c index 1112cb0de3..7b45ca7f55 100644 --- a/video/vdpau_mixer.c +++ b/video/vdpau_mixer.c @@ -197,9 +197,9 @@ static int create_vdp_mixer(struct mp_vdpau_mixer *mixer) VdpCSCMatrix matrix; struct mp_csp_params cparams = MP_CSP_PARAMS_DEFAULTS; - cparams.colorspace.format = mixer->image_params.colorspace; - cparams.colorspace.levels_in = mixer->image_params.colorlevels; - cparams.colorspace.levels_out = mixer->image_params.outputlevels; + cparams.colorspace = mixer->image_params.colorspace; + cparams.levels_in = mixer->image_params.colorlevels; + cparams.levels_out = mixer->image_params.outputlevels; mp_csp_copy_equalizer_values(&cparams, &mixer->video_eq); mp_get_yuv2rgb_coeffs(&cparams, matrix);