From d42d60bc1e0a1c3b472b21d3cd203279879f7d95 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 6 Jan 2015 16:49:53 +0100 Subject: csputils: replace float[3][4] with a struct Not being able to use the 3x3 part of the matrix was annoying, so split it into a float[3][3] matrix and a separate float[3] constant vector. --- sub/draw_bmp.c | 8 ++++---- sub/sd_ass.c | 14 +++++++------- sub/sd_lavc.c | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) (limited to 'sub') diff --git a/sub/draw_bmp.c b/sub/draw_bmp.c index 5e2ed41cd9..c5c0dddd29 100644 --- a/sub/draw_bmp.c +++ b/sub/draw_bmp.c @@ -294,11 +294,11 @@ static void draw_ass(struct mp_draw_sub_cache *cache, struct mp_rect bb, cspar.int_bits_in = bits; cspar.int_bits_out = 8; - float yuv2rgb[3][4], rgb2yuv[3][4]; + struct mp_cmat yuv2rgb, rgb2yuv; bool need_conv = temp->flags & MP_IMGFLAG_YUV; if (need_conv) { - mp_get_yuv2rgb_coeffs(&cspar, yuv2rgb); - mp_invert_yuv2rgb(rgb2yuv, yuv2rgb); + mp_get_yuv2rgb_coeffs(&cspar, &yuv2rgb); + mp_invert_yuv2rgb(&rgb2yuv, &yuv2rgb); } for (int i = 0; i < sbs->num_parts; ++i) { @@ -315,7 +315,7 @@ static void draw_ass(struct mp_draw_sub_cache *cache, struct mp_rect bb, int a = 255 - (sb->libass.color & 0xFF); int color_yuv[3] = {r, g, b}; if (need_conv) { - mp_map_int_color(rgb2yuv, bits, color_yuv); + mp_map_int_color(&rgb2yuv, bits, color_yuv); } else { color_yuv[0] = g; color_yuv[1] = b; diff --git a/sub/sd_ass.c b/sub/sd_ass.c index 8f5b02c842..8bfefb35cb 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -400,9 +400,9 @@ static void mangle_colors(struct sd *sd, struct sub_bitmaps *parts) 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]; - mp_get_yuv2rgb_coeffs(&vs_params, vs_yuv2rgb); - mp_invert_yuv2rgb(vs_rgb2yuv, vs_yuv2rgb); + struct mp_cmat vs_yuv2rgb, vs_rgb2yuv; + mp_get_yuv2rgb_coeffs(&vs_params, &vs_yuv2rgb); + mp_invert_yuv2rgb(&vs_rgb2yuv, &vs_yuv2rgb); // Proper conversion to RGB struct mp_csp_params rgb_params = MP_CSP_PARAMS_DEFAULTS; @@ -410,8 +410,8 @@ static void mangle_colors(struct sd *sd, struct sub_bitmaps *parts) rgb_params.levels_in = params.colorlevels; rgb_params.int_bits_in = 8; rgb_params.int_bits_out = 8; - float vs2rgb[3][4]; - mp_get_yuv2rgb_coeffs(&rgb_params, vs2rgb); + struct mp_cmat vs2rgb; + mp_get_yuv2rgb_coeffs(&rgb_params, &vs2rgb); for (int n = 0; n < parts->num_parts; n++) { struct sub_bitmap *sb = &parts->parts[n]; @@ -421,8 +421,8 @@ static void mangle_colors(struct sd *sd, struct sub_bitmaps *parts) int b = (color >> 8u) & 0xff; int a = 0xff - (color & 0xff); int c[3] = {r, g, b}; - mp_map_int_color(vs_rgb2yuv, 8, c); - mp_map_int_color(vs2rgb, 8, c); + mp_map_int_color(&vs_rgb2yuv, 8, c); + mp_map_int_color(&vs2rgb, 8, c); sb->libass.color = MP_ASS_RGBA(c[0], c[1], c[2], a); } } diff --git a/sub/sd_lavc.c b/sub/sd_lavc.c index 0a969efc41..4bdd6ea548 100644 --- a/sub/sd_lavc.c +++ b/sub/sd_lavc.c @@ -112,10 +112,10 @@ static void set_mp4_vobsub_idx(AVCodecContext *avctx, char *src, int w, int h) struct mp_csp_params csp = MP_CSP_PARAMS_DEFAULTS; csp.int_bits_in = 8; csp.int_bits_out = 8; - float cmatrix[3][4]; - mp_get_yuv2rgb_coeffs(&csp, cmatrix); + struct mp_cmat cmatrix; + mp_get_yuv2rgb_coeffs(&csp, &cmatrix); int c[3] = {(e >> 16) & 0xff, (e >> 8) & 0xff, e & 0xff}; - mp_map_int_color(cmatrix, 8, c); + mp_map_int_color(&cmatrix, 8, c); e = (c[2] << 16) | (c[1] << 8) | c[0]; snprintf(pal_s + pal_s_pos, sizeof(pal_s) - pal_s_pos, "%06x%s", e, -- cgit v1.2.3