Path: blob/master/dep/ffmpeg/include/libavutil/csp.h
4216 views
/*1* Copyright (c) 2015 Kevin Wheatley <[email protected]>2* Copyright (c) 2016 Ronald S. Bultje <[email protected]>3* Copyright (c) 2023 Leo Izen <[email protected]>4*5* This file is part of FFmpeg.6*7* FFmpeg is free software; you can redistribute it and/or8* modify it under the terms of the GNU Lesser General Public9* License as published by the Free Software Foundation; either10* version 2.1 of the License, or (at your option) any later version.11*12* FFmpeg is distributed in the hope that it will be useful,13* but WITHOUT ANY WARRANTY; without even the implied warranty of14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU15* Lesser General Public License for more details.16*17* You should have received a copy of the GNU Lesser General Public18* License along with FFmpeg; if not, write to the Free Software19* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA20*/2122#ifndef AVUTIL_CSP_H23#define AVUTIL_CSP_H2425#include "pixfmt.h"26#include "rational.h"2728/**29* @file30* Colorspace value utility functions for libavutil.31* @ingroup lavu_math_csp32* @author Ronald S. Bultje <[email protected]>33* @author Leo Izen <[email protected]>34* @author Kevin Wheatley <[email protected]>35*/3637/**38* @defgroup lavu_math_csp Colorspace Utility39* @ingroup lavu_math40* @{41*/4243/**44* Struct containing luma coefficients to be used for RGB to YUV/YCoCg, or similar45* calculations.46*/47typedef struct AVLumaCoefficients {48AVRational cr, cg, cb;49} AVLumaCoefficients;5051/**52* Struct containing chromaticity x and y values for the standard CIE 193153* chromaticity definition.54*/55typedef struct AVCIExy {56AVRational x, y;57} AVCIExy;5859/**60* Struct defining the red, green, and blue primary locations in terms of CIE61* 1931 chromaticity x and y.62*/63typedef struct AVPrimaryCoefficients {64AVCIExy r, g, b;65} AVPrimaryCoefficients;6667/**68* Struct defining white point location in terms of CIE 1931 chromaticity x69* and y.70*/71typedef AVCIExy AVWhitepointCoefficients;7273/**74* Struct that contains both white point location and primaries location, providing75* the complete description of a color gamut.76*/77typedef struct AVColorPrimariesDesc {78AVWhitepointCoefficients wp;79AVPrimaryCoefficients prim;80} AVColorPrimariesDesc;8182/**83* Function pointer representing a double -> double transfer function that performs84* an EOTF transfer inversion. This function outputs linear light.85*/86typedef double (*av_csp_trc_function)(double);8788/**89* Retrieves the Luma coefficients necessary to construct a conversion matrix90* from an enum constant describing the colorspace.91* @param csp An enum constant indicating YUV or similar colorspace.92* @return The Luma coefficients associated with that colorspace, or NULL93* if the constant is unknown to libavutil.94*/95const AVLumaCoefficients *av_csp_luma_coeffs_from_avcsp(enum AVColorSpace csp);9697/**98* Retrieves a complete gamut description from an enum constant describing the99* color primaries.100* @param prm An enum constant indicating primaries101* @return A description of the colorspace gamut associated with that enum102* constant, or NULL if the constant is unknown to libavutil.103*/104const AVColorPrimariesDesc *av_csp_primaries_desc_from_id(enum AVColorPrimaries prm);105106/**107* Detects which enum AVColorPrimaries constant corresponds to the given complete108* gamut description.109* @see enum AVColorPrimaries110* @param prm A description of the colorspace gamut111* @return The enum constant associated with this gamut, or112* AVCOL_PRI_UNSPECIFIED if no clear match can be idenitified.113*/114enum AVColorPrimaries av_csp_primaries_id_from_desc(const AVColorPrimariesDesc *prm);115116/**117* Determine a suitable 'gamma' value to match the supplied118* AVColorTransferCharacteristic.119*120* See Apple Technical Note TN2257 (https://developer.apple.com/library/mac/technotes/tn2257/_index.html)121*122* This function returns the gamma exponent for the OETF. For example, sRGB is approximated123* by gamma 2.2, not by gamma 0.45455.124*125* @return Will return an approximation to the simple gamma function matching126* the supplied Transfer Characteristic, Will return 0.0 for any127* we cannot reasonably match against.128*/129double av_csp_approximate_trc_gamma(enum AVColorTransferCharacteristic trc);130131/**132* Determine the function needed to apply the given133* AVColorTransferCharacteristic to linear input.134*135* The function returned should expect a nominal domain and range of [0.0-1.0]136* values outside of this range maybe valid depending on the chosen137* characteristic function.138*139* @return Will return pointer to the function matching the140* supplied Transfer Characteristic. If unspecified will141* return NULL:142*/143av_csp_trc_function av_csp_trc_func_from_id(enum AVColorTransferCharacteristic trc);144145/**146* @}147*/148149#endif /* AVUTIL_CSP_H */150151152