diff options
author | wm4 <wm4@nowhere> | 2012-10-27 18:01:51 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-10-28 15:31:32 +0100 |
commit | d9839fe8623c855b6b335df3a5b9783e3ed22266 (patch) | |
tree | b074361fef63d1a00b473e1859d373acb8c1e0e0 /libmpcodecs/mp_image.c | |
parent | 1ba8090df7e64885f717133d769f59808c3c8807 (diff) | |
download | mpv-d9839fe8623c855b6b335df3a5b9783e3ed22266.tar.bz2 mpv-d9839fe8623c855b6b335df3a5b9783e3ed22266.tar.xz |
mp_image: add fields to pass colorspace down the filter chain
Note that this also adds a RGB colorspace for general symmetry. The
frontend (colormatrix property and options) and
mp_get_yuv2rgb_coeffs() don't support this.
Diffstat (limited to 'libmpcodecs/mp_image.c')
-rw-r--r-- | libmpcodecs/mp_image.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/libmpcodecs/mp_image.c b/libmpcodecs/mp_image.c index b7c9017188..c0227e4b1d 100644 --- a/libmpcodecs/mp_image.c +++ b/libmpcodecs/mp_image.c @@ -249,3 +249,32 @@ void free_mp_image(mp_image_t* mpi){ talloc_free(mpi); } +enum mp_csp mp_image_csp(struct mp_image *img) +{ + if (img->colorspace != MP_CSP_AUTO) + return img->colorspace; + return (img->flags & MP_IMGFLAG_YUV) ? MP_CSP_BT_601 : MP_CSP_RGB; +} + +enum mp_csp_levels mp_image_levels(struct mp_image *img) +{ + if (img->levels != MP_CSP_LEVELS_AUTO) + return img->levels; + return (img->flags & MP_IMGFLAG_YUV) ? MP_CSP_LEVELS_TV : MP_CSP_LEVELS_PC; +} + +void mp_image_set_colorspace_details(struct mp_image *image, + struct mp_csp_details *csp) +{ + if (image->flags & MP_IMGFLAG_YUV) { + image->colorspace = csp->format; + if (image->colorspace == MP_CSP_AUTO) + image->colorspace = MP_CSP_BT_601; + image->levels = csp->levels_in; + if (image->levels == MP_CSP_LEVELS_AUTO) + image->levels = MP_CSP_LEVELS_TV; + } else { + image->colorspace = MP_CSP_RGB; + image->levels = MP_CSP_LEVELS_PC; + } +} |