From d81fb97f4587f73f62a760b99f686139f9b8d966 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Wed, 29 Jun 2016 09:16:13 +0200 Subject: mp_image: split colorimetry metadata into its own struct MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- video/filter/vf_d3d11vpp.c | 12 ++++++------ video/filter/vf_format.c | 10 +++++----- video/filter/vf_scale.c | 4 ++-- video/filter/vf_vapoursynth.c | 6 +++--- video/filter/vf_vavpp.c | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) (limited to 'video/filter') diff --git a/video/filter/vf_d3d11vpp.c b/video/filter/vf_d3d11vpp.c index a0aa0edae2..658aec25b8 100644 --- a/video/filter/vf_d3d11vpp.c +++ b/video/filter/vf_d3d11vpp.c @@ -211,21 +211,21 @@ static int recreate_video_proc(struct vf_instance *vf) FALSE, 0); D3D11_VIDEO_PROCESSOR_COLOR_SPACE csp = { - .YCbCr_Matrix = p->params.colorspace != MP_CSP_BT_601, - .Nominal_Range = p->params.colorlevels == MP_CSP_LEVELS_TV ? 1 : 2, + .YCbCr_Matrix = p->params.color.space != MP_CSP_BT_601, + .Nominal_Range = p->params.color.levels == MP_CSP_LEVELS_TV ? 1 : 2, }; ID3D11VideoContext_VideoProcessorSetStreamColorSpace(p->video_ctx, p->video_proc, 0, &csp); if (p->out_rgb) { - if (p->params.colorspace != MP_CSP_BT_601 && - p->params.colorspace != MP_CSP_BT_709) + if (p->params.color.space != MP_CSP_BT_601 && + p->params.color.space != MP_CSP_BT_709) { MP_WARN(vf, "Unsupported video colorspace (%s/%s). Consider " "disabling hardware decoding, or using " "--hwdec=d3d11va-copy to get correct output.\n", - m_opt_choice_str(mp_csp_names, p->params.colorspace), - m_opt_choice_str(mp_csp_levels_names, p->params.colorlevels)); + m_opt_choice_str(mp_csp_names, p->params.color.space), + m_opt_choice_str(mp_csp_levels_names, p->params.color.levels)); } } else { ID3D11VideoContext_VideoProcessorSetOutputColorSpace(p->video_ctx, diff --git a/video/filter/vf_format.c b/video/filter/vf_format.c index 109fda4053..36388e6288 100644 --- a/video/filter/vf_format.c +++ b/video/filter/vf_format.c @@ -88,15 +88,15 @@ static int reconfig(struct vf_instance *vf, struct mp_image_params *in, if (p->outfmt) out->imgfmt = p->outfmt; if (p->colormatrix) - out->colorspace = p->colormatrix; + out->color.space = p->colormatrix; if (p->colorlevels) - out->colorlevels = p->colorlevels; + out->color.levels = p->colorlevels; if (p->primaries) - out->primaries = p->primaries; + out->color.primaries = p->primaries; if (p->gamma) - out->gamma = p->gamma; + out->color.gamma = p->gamma; if (p->peak) - out->peak = p->peak; + out->color.peak = p->peak; if (p->chroma_location) out->chroma_location = p->chroma_location; if (p->stereo_in) diff --git a/video/filter/vf_scale.c b/video/filter/vf_scale.c index 518ff41beb..0b233e7098 100644 --- a/video/filter/vf_scale.c +++ b/video/filter/vf_scale.c @@ -166,8 +166,8 @@ static int reconfig(struct vf_instance *vf, struct mp_image_params *in, struct mp_imgfmt_desc d_fmt = mp_imgfmt_get_desc(out->imgfmt); // keep colorspace settings if the data stays in yuv if (!(s_fmt.flags & MP_IMGFLAG_YUV) || !(d_fmt.flags & MP_IMGFLAG_YUV)) { - out->colorspace = MP_CSP_AUTO; - out->colorlevels = MP_CSP_LEVELS_AUTO; + out->color.space = MP_CSP_AUTO; + out->color.levels = MP_CSP_LEVELS_AUTO; } mp_image_params_guess_csp(out); diff --git a/video/filter/vf_vapoursynth.c b/video/filter/vf_vapoursynth.c index 5592e032e4..625d539dc4 100644 --- a/video/filter/vf_vapoursynth.c +++ b/video/filter/vf_vapoursynth.c @@ -143,13 +143,13 @@ static void copy_mp_to_vs_frame_props_map(struct vf_priv_s *p, VSMap *map, struct mp_image_params *params = &img->params; p->vsapi->propSetInt(map, "_SARNum", params->p_w, 0); p->vsapi->propSetInt(map, "_SARDen", params->p_h, 0); - if (params->colorlevels) { + if (params->color.levels) { p->vsapi->propSetInt(map, "_ColorRange", - params->colorlevels == MP_CSP_LEVELS_TV, 0); + params->color.levels == MP_CSP_LEVELS_TV, 0); } // The docs explicitly say it uses libavcodec values. p->vsapi->propSetInt(map, "_ColorSpace", - mp_csp_to_avcol_spc(params->colorspace), 0); + mp_csp_to_avcol_spc(params->color.space), 0); if (params->chroma_location) { p->vsapi->propSetInt(map, "_ChromaLocation", params->chroma_location == MP_CHROMA_CENTER, 0); diff --git a/video/filter/vf_vavpp.c b/video/filter/vf_vavpp.c index 0365b55fb3..b24f886241 100644 --- a/video/filter/vf_vavpp.c +++ b/video/filter/vf_vavpp.c @@ -168,7 +168,7 @@ static struct mp_image *render(struct vf_instance *vf) mp_image_set_size(img, in->w, in->h); mp_image_copy_attributes(img, in); - unsigned int flags = va_get_colorspace_flag(p->params.colorspace); + unsigned int flags = va_get_colorspace_flag(p->params.color.space); if (!mp_refqueue_is_interlaced(p->queue)) { flags |= VA_FRAME_PICTURE; } else if (mp_refqueue_is_top_field(p->queue)) { -- cgit v1.2.3