summaryrefslogtreecommitdiffstats
path: root/sub
diff options
context:
space:
mode:
authorNiklas Haas <git@nand.wakku.to>2016-06-29 09:16:13 +0200
committerwm4 <wm4@nowhere>2016-07-03 19:42:52 +0200
commitd81fb97f4587f73f62a760b99f686139f9b8d966 (patch)
treef97ec972e64160e1a479c1b31daf73af32ca54e1 /sub
parent3abf9c9204e2fcbc1910deb102efab4ab9d8c149 (diff)
downloadmpv-d81fb97f4587f73f62a760b99f686139f9b8d966.tar.bz2
mpv-d81fb97f4587f73f62a760b99f686139f9b8d966.tar.xz
mp_image: split colorimetry metadata into its own struct
This has two reasons: 1. I tend to add new fields to this metadata, and every time I've done so I've consistently forgotten to update all of the dozens of places in which this colorimetry metadata might end up getting used. While most usages don't really care about most of the metadata, sometimes the intend was simply to “copy” the colorimetry metadata from one struct to another. With this being inside a substruct, those lines of code can now simply read a.color = b.color without having to care about added or removed fields. 2. It makes the type definitions nicer for upcoming refactors. In going through all of the usages, I also expanded a few where I felt that omitting the “young” fields was a bug.
Diffstat (limited to 'sub')
-rw-r--r--sub/draw_bmp.c17
-rw-r--r--sub/sd_ass.c27
2 files changed, 21 insertions, 23 deletions
diff --git a/sub/draw_bmp.c b/sub/draw_bmp.c
index 5356a8fa99..b79810ce9a 100644
--- a/sub/draw_bmp.c
+++ b/sub/draw_bmp.c
@@ -193,8 +193,7 @@ static void scale_sb_rgba(struct sub_bitmap *sb, struct mp_image *dst_format,
mp_image_swscale(sbisrc2, &sbisrc, SWS_BILINEAR);
unpremultiply_and_split_BGR32(sbisrc2, sba);
- sbi->params.colorspace = dst_format->params.colorspace;
- sbi->params.colorlevels = dst_format->params.colorlevels;
+ sbi->params.color = dst_format->params.color;
mp_image_swscale(sbi, sbisrc2, SWS_BILINEAR);
talloc_free(sbisrc2);
@@ -367,8 +366,8 @@ static struct part *get_cache(struct mp_draw_sub_cache *cache,
if (part) {
if (part->change_id != sbs->change_id
|| part->imgfmt != format->imgfmt
- || part->colorspace != format->params.colorspace
- || part->levels != format->params.colorlevels)
+ || part->colorspace != format->params.color.space
+ || part->levels != format->params.color.levels)
{
talloc_free(part);
part = NULL;
@@ -380,8 +379,8 @@ static struct part *get_cache(struct mp_draw_sub_cache *cache,
.change_id = sbs->change_id,
.num_imgs = sbs->num_parts,
.imgfmt = format->imgfmt,
- .levels = format->params.colorlevels,
- .colorspace = format->params.colorspace,
+ .levels = format->params.color.levels,
+ .colorspace = format->params.color.space,
};
part->imgs = talloc_zero_array(part, struct sub_cache,
part->num_imgs);
@@ -436,10 +435,8 @@ static struct mp_image *chroma_up(struct mp_draw_sub_cache *cache, int imgfmt,
// The temp image is always YUV, but src not necessarily.
// Reduce amount of conversions in YUV case (upsampling/shifting only)
- if (src->fmt.flags & MP_IMGFLAG_YUV) {
- temp->params.colorspace = src->params.colorspace;
- temp->params.colorlevels = src->params.colorlevels;
- }
+ if (src->fmt.flags & MP_IMGFLAG_YUV)
+ temp->params.color = src->params.color;
if (src->imgfmt == IMGFMT_420P) {
assert(imgfmt == IMGFMT_444P);
diff --git a/sub/sd_ass.c b/sub/sd_ass.c
index 7abeea9eeb..34a49c1501 100644
--- a/sub/sd_ass.c
+++ b/sub/sd_ass.c
@@ -733,15 +733,17 @@ static void mangle_colors(struct sd *sd, struct sub_bitmaps *parts)
struct mp_image_params params = ctx->video_params;
if (force_601) {
- params.colorspace = MP_CSP_BT_709;
- params.colorlevels = MP_CSP_LEVELS_TV;
+ params.color = (struct mp_colorspace){
+ .space = MP_CSP_BT_709,
+ .levels = MP_CSP_LEVELS_TV,
+ };
}
- if (csp == params.colorspace && levels == params.colorlevels)
+ if (csp == params.color.space && levels == params.color.levels)
return;
- bool basic_conv = params.colorspace == MP_CSP_BT_709 &&
- params.colorlevels == MP_CSP_LEVELS_TV &&
+ bool basic_conv = params.color.space == MP_CSP_BT_709 &&
+ params.color.levels == MP_CSP_LEVELS_TV &&
csp == MP_CSP_BT_601 &&
levels == MP_CSP_LEVELS_TV;
@@ -749,8 +751,8 @@ static void mangle_colors(struct sd *sd, struct sub_bitmaps *parts)
if (opts->ass_vsfilter_color_compat == 1 && !basic_conv)
return;
- if (params.colorspace != ctx->last_params.colorspace ||
- params.colorlevels != ctx->last_params.colorlevels)
+ if (params.color.space != ctx->last_params.color.space ||
+ params.color.levels != ctx->last_params.color.levels)
{
int msgl = basic_conv ? MSGL_V : MSGL_WARN;
ctx->last_params = params;
@@ -758,22 +760,21 @@ static void mangle_colors(struct sd *sd, struct sub_bitmaps *parts)
"RGB -> %s %s -> %s %s -> RGB\n",
m_opt_choice_str(mp_csp_names, csp),
m_opt_choice_str(mp_csp_levels_names, levels),
- m_opt_choice_str(mp_csp_names, params.colorspace),
- m_opt_choice_str(mp_csp_names, params.colorlevels));
+ m_opt_choice_str(mp_csp_names, params.color.space),
+ m_opt_choice_str(mp_csp_names, params.color.levels));
}
// Conversion that VSFilter would use
struct mp_csp_params vs_params = MP_CSP_PARAMS_DEFAULTS;
- vs_params.colorspace = csp;
- vs_params.levels_in = levels;
+ vs_params.color.space = csp;
+ vs_params.color.levels = levels;
struct mp_cmat vs_yuv2rgb, vs_rgb2yuv;
mp_get_csp_matrix(&vs_params, &vs_yuv2rgb);
mp_invert_cmat(&vs_rgb2yuv, &vs_yuv2rgb);
// Proper conversion to RGB
struct mp_csp_params rgb_params = MP_CSP_PARAMS_DEFAULTS;
- rgb_params.colorspace = params.colorspace;
- rgb_params.levels_in = params.colorlevels;
+ rgb_params.color = params.color;
struct mp_cmat vs2rgb;
mp_get_csp_matrix(&rgb_params, &vs2rgb);