summaryrefslogtreecommitdiffstats
path: root/video/out
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 /video/out
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 'video/out')
-rw-r--r--video/out/opengl/hwdec_vaglx.c2
-rw-r--r--video/out/opengl/video.c30
-rw-r--r--video/out/vo_lavc.c4
-rw-r--r--video/out/vo_opengl.c6
-rw-r--r--video/out/vo_rpi.c2
-rw-r--r--video/out/vo_vaapi.c2
-rw-r--r--video/out/vo_xv.c4
7 files changed, 26 insertions, 24 deletions
diff --git a/video/out/opengl/hwdec_vaglx.c b/video/out/opengl/hwdec_vaglx.c
index 2e3017c193..0400604067 100644
--- a/video/out/opengl/hwdec_vaglx.c
+++ b/video/out/opengl/hwdec_vaglx.c
@@ -185,7 +185,7 @@ static int map_frame(struct gl_hwdec *hw, struct mp_image *hw_image,
0, 0, hw_image->w, hw_image->h,
0, 0, hw_image->w, hw_image->h,
NULL, 0,
- va_get_colorspace_flag(hw_image->params.colorspace));
+ va_get_colorspace_flag(hw_image->params.color.space));
CHECK_VA_STATUS(p, "vaPutSurface()");
va_unlock(p->ctx);
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index 6c7646bef4..59dd64cb65 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -729,7 +729,7 @@ static void pass_get_img_tex(struct gl_video *p, struct video_image *vimg,
// The existing code assumes we just have a single tex multiplier for
// all of the planes. This may change in the future
- float tex_mul = 1.0 / mp_get_csp_mul(p->image_params.colorspace,
+ float tex_mul = 1.0 / mp_get_csp_mul(p->image_params.color.space,
p->image_desc.component_bits,
p->image_desc.component_full_bits);
@@ -793,7 +793,7 @@ static void init_video(struct gl_video *p)
mp_image_params_guess_csp(&p->image_params);
int eq_caps = MP_CSP_EQ_CAPS_GAMMA;
- if (p->image_params.colorspace != MP_CSP_BT_2020_C)
+ if (p->image_params.color.space != MP_CSP_BT_2020_C)
eq_caps |= MP_CSP_EQ_CAPS_COLORMATRIX;
if (p->image_desc.flags & MP_IMGFLAG_XYZ)
eq_caps |= MP_CSP_EQ_CAPS_BRIGHTNESS;
@@ -1985,7 +1985,7 @@ static void pass_convert_yuv(struct gl_video *p)
GLSLF("color = color.%s;\n", p->color_swizzle);
// Pre-colormatrix input gamma correction
- if (cparams.colorspace == MP_CSP_XYZ)
+ if (cparams.color.space == MP_CSP_XYZ)
GLSL(color.rgb = pow(color.rgb, vec3(2.6));) // linear light
// We always explicitly normalize the range in pass_read_video
@@ -2000,7 +2000,7 @@ static void pass_convert_yuv(struct gl_video *p)
GLSL(color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;)
- if (p->image_params.colorspace == MP_CSP_BT_2020_C) {
+ if (p->image_params.color.space == MP_CSP_BT_2020_C) {
// Conversion for C'rcY'cC'bc via the BT.2020 CL system:
// C'bc = (B'-Y'c) / 1.9404 | C'bc <= 0
// = (B'-Y'c) / 1.5816 | C'bc > 0
@@ -2111,7 +2111,7 @@ static void pass_scale_main(struct gl_video *p)
// Pre-conversion, like linear light/sigmoidization
GLSLF("// scaler pre-conversion\n");
if (p->use_linear) {
- pass_linearize(p->sc, p->image_params.gamma);
+ pass_linearize(p->sc, p->image_params.color.gamma);
pass_opt_hook_point(p, "LINEAR", NULL);
}
@@ -2171,8 +2171,8 @@ static void pass_colormanage(struct gl_video *p, float peak_src,
if (p->use_lut_3d) {
// The 3DLUT is always generated against the original source space
- enum mp_csp_prim prim_orig = p->image_params.primaries;
- enum mp_csp_trc trc_orig = p->image_params.gamma;
+ enum mp_csp_prim prim_orig = p->image_params.color.primaries;
+ enum mp_csp_trc trc_orig = p->image_params.color.gamma;
// One exception: HDR is not implemented by LittleCMS for technical
// limitation reasons, so we use a gamma 2.2 input curve here instead.
@@ -2196,14 +2196,14 @@ static void pass_colormanage(struct gl_video *p, float peak_src,
// this as the default output color space.
prim_dst = MP_CSP_PRIM_BT_709;
- if (p->image_params.primaries == MP_CSP_PRIM_BT_601_525 ||
- p->image_params.primaries == MP_CSP_PRIM_BT_601_625)
+ if (p->image_params.color.primaries == MP_CSP_PRIM_BT_601_525 ||
+ p->image_params.color.primaries == MP_CSP_PRIM_BT_601_625)
{
// Since we auto-pick BT.601 and BT.709 based on the dimensions,
// combined with the fact that they're very similar to begin with,
// and to avoid confusing the average user, just don't adapt BT.601
// content automatically at all.
- prim_dst = p->image_params.primaries;
+ prim_dst = p->image_params.color.primaries;
}
}
@@ -2213,7 +2213,7 @@ static void pass_colormanage(struct gl_video *p, float peak_src,
// altogether by default. The only exceptions to this rule apply to
// very unusual TRCs, which even hardcode technoluddites would probably
// not enjoy viewing unaltered.
- trc_dst = p->image_params.gamma;
+ trc_dst = p->image_params.color.gamma;
// Avoid outputting linear light or HDR content "by default". For these
// just pick gamma 2.2 as a default, since it's a good estimate for
@@ -2225,7 +2225,7 @@ static void pass_colormanage(struct gl_video *p, float peak_src,
if (!peak_src) {
// If the source has no information known, it's display-referred
// (and should be treated relative to the specified desired peak_dst)
- peak_src = peak_dst * mp_csp_trc_rel_peak(p->image_params.gamma);
+ peak_src = peak_dst * mp_csp_trc_rel_peak(p->image_params.color.gamma);
}
// All operations from here on require linear light as a starting point,
@@ -2513,7 +2513,7 @@ static void pass_render_frame(struct gl_video *p)
rect.mt *= scale[1]; rect.mb *= scale[1];
// We should always blend subtitles in non-linear light
if (p->use_linear) {
- pass_delinearize(p->sc, p->image_params.gamma);
+ pass_delinearize(p->sc, p->image_params.color.gamma);
p->use_linear = false;
}
finish_pass_fbo(p, &p->blend_subs_fbo, p->texture_w, p->texture_h,
@@ -2542,8 +2542,8 @@ static void pass_draw_to_screen(struct gl_video *p, int fbo)
GLSL(color.rgb = pow(color.rgb, vec3(user_gamma));)
}
- pass_colormanage(p, p->image_params.peak, p->image_params.primaries,
- p->use_linear ? MP_CSP_TRC_LINEAR : p->image_params.gamma);
+ pass_colormanage(p, p->image_params.color.peak, p->image_params.color.primaries,
+ p->use_linear ? MP_CSP_TRC_LINEAR : p->image_params.color.gamma);
// Draw checkerboard pattern to indicate transparency
if (p->has_alpha && p->opts.alpha_mode == ALPHA_BLEND_TILES) {
diff --git a/video/out/vo_lavc.c b/video/out/vo_lavc.c
index 7003bd17bd..1721136f8b 100644
--- a/video/out/vo_lavc.c
+++ b/video/out/vo_lavc.c
@@ -155,8 +155,8 @@ static int reconfig(struct vo *vo, struct mp_image_params *params)
vc->codec->height = height;
vc->codec->pix_fmt = pix_fmt;
- encode_lavc_set_csp(vo->encode_lavc_ctx, vc->codec, params->colorspace);
- encode_lavc_set_csp_levels(vo->encode_lavc_ctx, vc->codec, params->colorlevels);
+ encode_lavc_set_csp(vo->encode_lavc_ctx, vc->codec, params->color.space);
+ encode_lavc_set_csp_levels(vo->encode_lavc_ctx, vc->codec, params->color.levels);
if (encode_lavc_open_codec(vo->encode_lavc_ctx, vc->codec) < 0)
goto error;
diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c
index 08b9b11fe0..095308f9b5 100644
--- a/video/out/vo_opengl.c
+++ b/video/out/vo_opengl.c
@@ -305,8 +305,10 @@ static int control(struct vo *vo, uint32_t request, void *data)
struct mp_image *screen = gl_read_window_contents(p->gl);
// set image parameters according to the display, if possible
if (screen) {
- screen->params.primaries = p->renderer_opts->target_prim;
- screen->params.gamma = p->renderer_opts->target_trc;
+ screen->params.color = (struct mp_colorspace) {
+ .primaries = p->renderer_opts->target_prim,
+ .gamma = p->renderer_opts->target_trc,
+ };
if (p->glctx->flip_v)
mp_image_vflip(screen);
}
diff --git a/video/out/vo_rpi.c b/video/out/vo_rpi.c
index cd37362a30..947e63037e 100644
--- a/video/out/vo_rpi.c
+++ b/video/out/vo_rpi.c
@@ -529,7 +529,7 @@ static int reconfig(struct vo *vo, struct mp_image_params *params)
input->format->es->video.height = MP_ALIGN_UP(params->h, ALIGN_H);
input->format->es->video.crop = (MMAL_RECT_T){0, 0, params->w, params->h};
input->format->es->video.par = (MMAL_RATIONAL_T){params->p_w, params->p_h};
- input->format->es->video.color_space = map_csp(params->colorspace);
+ input->format->es->video.color_space = map_csp(params->color.space);
if (mmal_port_format_commit(input))
return -1;
diff --git a/video/out/vo_vaapi.c b/video/out/vo_vaapi.c
index 8380771e27..11bb469b24 100644
--- a/video/out/vo_vaapi.c
+++ b/video/out/vo_vaapi.c
@@ -225,7 +225,7 @@ static bool render_to_screen(struct priv *p, struct mp_image *mpi)
}
}
- int flags = va_get_colorspace_flag(p->image_params.colorspace) |
+ int flags = va_get_colorspace_flag(p->image_params.color.space) |
p->scaling | VA_FRAME_PICTURE;
status = vaPutSurface(p->display,
surface,
diff --git a/video/out/vo_xv.c b/video/out/vo_xv.c
index a5a4728085..f450eb2df9 100644
--- a/video/out/vo_xv.c
+++ b/video/out/vo_xv.c
@@ -518,7 +518,7 @@ static int reconfig(struct vo *vo, struct mp_image_params *params)
ctx->current_buf = 0;
ctx->current_ip_buf = 0;
- int is_709 = params->colorspace == MP_CSP_BT_709;
+ int is_709 = params->color.space == MP_CSP_BT_709;
xv_set_eq(vo, ctx->xv_port, "bt_709", is_709 * 200 - 100);
read_xv_csp(vo);
@@ -661,7 +661,7 @@ static struct mp_image get_xv_buffer(struct vo *vo, int buf_index)
if (vo->params) {
struct mp_image_params params = *vo->params;
if (ctx->cached_csp)
- params.colorspace = ctx->cached_csp;
+ params.color.space = ctx->cached_csp;
mp_image_set_attributes(&img, &params);
}