From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH v5 1/1] avutil/csp: create public API for colorspace structs
Date: Tue, 24 May 2022 22:56:14 +0200
Message-ID: <DB6PR0101MB22145C389A997187EDD309BB8FD79@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com> (raw)
In-Reply-To: <20220524163001.55360-2-leo.izen@gmail.com>
Leo Izen:
> This commit moves some of the functionality from avfilter/colorspace
> into avutil/csp and exposes it as a public API so it can be used by
> libavcodec and/or libavformat. It also converts those structs from
> double values to AVRational to make regression testing easier and
> more consistent.
> ---
> libavfilter/colorspace.c | 143 ++++++++----------------------------
> libavfilter/colorspace.h | 31 +-------
> libavfilter/fflcms2.c | 33 +++++----
> libavfilter/fflcms2.h | 4 +-
> libavfilter/vf_colorspace.c | 37 +++++-----
> libavfilter/vf_iccdetect.c | 5 +-
> libavfilter/vf_tonemap.c | 17 +----
> libavutil/Makefile | 2 +
> libavutil/csp.c | 128 ++++++++++++++++++++++++++++++++
> libavutil/csp.h | 115 +++++++++++++++++++++++++++++
> libavutil/version.h | 2 +-
> 11 files changed, 326 insertions(+), 191 deletions(-)
> create mode 100644 libavutil/csp.c
> create mode 100644 libavutil/csp.h
> > diff --git a/libavutil/csp.h b/libavutil/csp.h
> new file mode 100644
> index 0000000000..57a615c678
> --- /dev/null
> +++ b/libavutil/csp.h
> @@ -0,0 +1,115 @@
> +/*
> + * Copyright (c) 2016 Ronald S. Bultje <rsbultje@gmail.com>
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#ifndef AVUTIL_CSP_H
> +#define AVUTIL_CSP_H
> +
> +#include "pixfmt.h"
> +#include "rational.h"
> +
> +/**
> + * @file Colorspace value utility functions for libavutil.
> + * @author Ronald S. Bultje <rsbultje@gmail.com>
> + * @author Leo Izen <leo.izen@gmail.com>
> + * @defgroup lavu_math_csp Colorspace Utility
> + * @ingroup lavu_math
> + * @{
> + */
> +
> +/**
> + * This denominator should be used when converting float or double values to
> + * AVRational so they can work with this API, because it provides significant
> + * enough precision to be visually identical to the floating point values.
> + * @see av_d2q()
> + */
> +#define AVUTIL_CSP_DENOM 100000
Why not 300000 given that the denominator of one of the constants has a
factor of three?
(Sorry if this has already been answered before.)
> +
> +/**
> + * Struct containing luma coefficients to be used for RGB to YUV calculations,
> + * or YUV to RGB.
> + */
> +typedef struct AVLumaCoefficients {
> + AVRational cr, cg, cb;
> +} AVLumaCoefficients;
> +
> +/**
> + * Struct containing chromaticity x and y values for the standard CIE 1931
> + * chromaticity definition.
> + */
> +typedef struct AVCIExy {
> + AVRational x, y;
> +} AVCIExy;
> +
> +/**
> + * Struct defining the red, green, and blue primary locations in terms of CIE
> + * 1931 chromaticity x and y.
> + */
> +typedef struct AVPrimaryCoefficients {
> + AVCIExy r, g, b;
> +} AVPrimaryCoefficients;
> +
> +/**
> + * Struct defining white point location in terms of CIE 1931 chromaticity x
> + * and y.
> + */
> +typedef AVCIExy AVWhitepointCoefficients;
> +
> +/**
> + * Struct that contains both white point location and primaries location, providing
> + * the complete description of a color gamut.
> + */
> +typedef struct AVColorPrimariesDesc {
> + AVWhitepointCoefficients wp;
> + AVPrimaryCoefficients prim;
> +} AVColorPrimariesDesc;
> +
> +
> +/**
> + * Detects which enum AVColorPrimaries constant corresponds to the given complete
> + * gamut description.
> + * @see enum AVColorPrimaries
> + * @param prm A description of the colorspace gamut
> + * @return The enum constant associated with this gamut, or
> + * AVCOL_PRI_UNSPECIFIED if no clear match can be idenitified.
> + */
> +enum AVColorPrimaries av_csp_primaries_id_from_desc(const AVColorPrimariesDesc *prm);
> +
> +/**
> + * Retrieves a complete gamut description from an enum constant describing the
> + * color primaries.
> + * @param prm An enum constant indicating primaries
> + * @return A description of the colorspace gamut associated with that enum
> + * constant, or NULL if the constant is unknown to libavutil.
> + */
> +const AVColorPrimariesDesc *av_csp_primaries_desc_from_id(enum AVColorPrimaries prm);
> +
> +/**
> + * Retrieves the Luma coefficients necessary to construct a conversion matrix
> + * from an enum constant describing the YUV colorspace.
> + * @param csp An enum constant indicating YUV colorspace.
> + * @return The Luma coefficients associated with that YUV colorspace, or NULL
> + * if the constant is unknown to libavutil.
> + */
> +const AVLumaCoefficients *av_csp_luma_coeffs_from_avcsp(enum AVColorSpace csp);
> +
> +/**
> + * @}
> + */
> +
> +#endif /* AVUTIL_CSP_H */
> diff --git a/libavutil/version.h b/libavutil/version.h
> index 1b4b41d81f..2c7f4f6b37 100644
> --- a/libavutil/version.h
> +++ b/libavutil/version.h
> @@ -79,7 +79,7 @@
> */
>
> #define LIBAVUTIL_VERSION_MAJOR 57
> -#define LIBAVUTIL_VERSION_MINOR 25
> +#define LIBAVUTIL_VERSION_MINOR 26
> #define LIBAVUTIL_VERSION_MICRO 100
>
> #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-05-24 20:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-24 16:30 [FFmpeg-devel] [PATCH v5 0/1] " Leo Izen
2022-05-24 16:30 ` [FFmpeg-devel] [PATCH v5 1/1] " Leo Izen
2022-05-24 20:56 ` Andreas Rheinhardt [this message]
2022-05-24 21:51 ` Leo Izen
2022-05-28 10:42 ` Andreas Rheinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DB6PR0101MB22145C389A997187EDD309BB8FD79@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com \
--to=andreas.rheinhardt@outlook.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git