csp.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (c) 2016 Ronald S. Bultje <rsbultje@gmail.com>
  3. * This file is part of FFmpeg.
  4. *
  5. * FFmpeg is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * FFmpeg is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with FFmpeg; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. */
  19. #ifndef AVUTIL_CSP_H
  20. #define AVUTIL_CSP_H
  21. #include "pixfmt.h"
  22. #include "rational.h"
  23. /**
  24. * @file Colorspace value utility functions for libavutil.
  25. * @author Ronald S. Bultje <rsbultje@gmail.com>
  26. * @author Leo Izen <leo.izen@gmail.com>
  27. * @defgroup lavu_math_csp Colorspace Utility
  28. * @ingroup lavu_math
  29. * @{
  30. */
  31. /**
  32. * Struct containing luma coefficients to be used for RGB to YUV/YCoCg, or similar
  33. * calculations.
  34. */
  35. typedef struct AVLumaCoefficients {
  36. AVRational cr, cg, cb;
  37. } AVLumaCoefficients;
  38. /**
  39. * Struct containing chromaticity x and y values for the standard CIE 1931
  40. * chromaticity definition.
  41. */
  42. typedef struct AVCIExy {
  43. AVRational x, y;
  44. } AVCIExy;
  45. /**
  46. * Struct defining the red, green, and blue primary locations in terms of CIE
  47. * 1931 chromaticity x and y.
  48. */
  49. typedef struct AVPrimaryCoefficients {
  50. AVCIExy r, g, b;
  51. } AVPrimaryCoefficients;
  52. /**
  53. * Struct defining white point location in terms of CIE 1931 chromaticity x
  54. * and y.
  55. */
  56. typedef AVCIExy AVWhitepointCoefficients;
  57. /**
  58. * Struct that contains both white point location and primaries location, providing
  59. * the complete description of a color gamut.
  60. */
  61. typedef struct AVColorPrimariesDesc {
  62. AVWhitepointCoefficients wp;
  63. AVPrimaryCoefficients prim;
  64. } AVColorPrimariesDesc;
  65. /**
  66. * Retrieves the Luma coefficients necessary to construct a conversion matrix
  67. * from an enum constant describing the colorspace.
  68. * @param csp An enum constant indicating YUV or similar colorspace.
  69. * @return The Luma coefficients associated with that colorspace, or NULL
  70. * if the constant is unknown to libavutil.
  71. */
  72. const AVLumaCoefficients *av_csp_luma_coeffs_from_avcsp(enum AVColorSpace csp);
  73. /**
  74. * Retrieves a complete gamut description from an enum constant describing the
  75. * color primaries.
  76. * @param prm An enum constant indicating primaries
  77. * @return A description of the colorspace gamut associated with that enum
  78. * constant, or NULL if the constant is unknown to libavutil.
  79. */
  80. const AVColorPrimariesDesc *av_csp_primaries_desc_from_id(enum AVColorPrimaries prm);
  81. /**
  82. * Detects which enum AVColorPrimaries constant corresponds to the given complete
  83. * gamut description.
  84. * @see enum AVColorPrimaries
  85. * @param prm A description of the colorspace gamut
  86. * @return The enum constant associated with this gamut, or
  87. * AVCOL_PRI_UNSPECIFIED if no clear match can be idenitified.
  88. */
  89. enum AVColorPrimaries av_csp_primaries_id_from_desc(const AVColorPrimariesDesc *prm);
  90. /**
  91. * @}
  92. */
  93. #endif /* AVUTIL_CSP_H */