video-color.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /* GStreamer
  2. * Copyright (C) <2011> Wim Taymans <[email protected]>
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Library General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Library General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Library General Public
  15. * License along with this library; if not, write to the
  16. * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  17. * Boston, MA 02110-1301, USA.
  18. */
  19. #ifndef __GST_VIDEO_COLOR_H__
  20. #define __GST_VIDEO_COLOR_H__
  21. #include <gst/gst.h>
  22. #include <gst/video/video-format.h>
  23. G_BEGIN_DECLS
  24. /**
  25. * GstVideoColorRange:
  26. * @GST_VIDEO_COLOR_RANGE_UNKNOWN: unknown range
  27. * @GST_VIDEO_COLOR_RANGE_0_255: [0..255] for 8 bit components
  28. * @GST_VIDEO_COLOR_RANGE_16_235: [16..235] for 8 bit components. Chroma has
  29. * [16..240] range.
  30. *
  31. * Possible color range values. These constants are defined for 8 bit color
  32. * values and can be scaled for other bit depths.
  33. */
  34. typedef enum {
  35. GST_VIDEO_COLOR_RANGE_UNKNOWN = 0,
  36. GST_VIDEO_COLOR_RANGE_0_255,
  37. GST_VIDEO_COLOR_RANGE_16_235
  38. } GstVideoColorRange;
  39. /**
  40. * GstVideoColorMatrix:
  41. * @GST_VIDEO_COLOR_MATRIX_UNKNOWN: unknown matrix
  42. * @GST_VIDEO_COLOR_MATRIX_RGB: identity matrix
  43. * @GST_VIDEO_COLOR_MATRIX_FCC: FCC color matrix
  44. * @GST_VIDEO_COLOR_MATRIX_BT709: ITU-R BT.709 color matrix
  45. * @GST_VIDEO_COLOR_MATRIX_BT601: ITU-R BT.601 color matrix
  46. * @GST_VIDEO_COLOR_MATRIX_SMPTE240M: SMPTE 240M color matrix
  47. *
  48. * The color matrix is used to convert between Y'PbPr and
  49. * non-linear RGB (R'G'B')
  50. */
  51. typedef enum {
  52. GST_VIDEO_COLOR_MATRIX_UNKNOWN = 0,
  53. GST_VIDEO_COLOR_MATRIX_RGB,
  54. GST_VIDEO_COLOR_MATRIX_FCC,
  55. GST_VIDEO_COLOR_MATRIX_BT709,
  56. GST_VIDEO_COLOR_MATRIX_BT601,
  57. GST_VIDEO_COLOR_MATRIX_SMPTE240M
  58. } GstVideoColorMatrix;
  59. /**
  60. * GstVideoTransferFunction:
  61. * @GST_VIDEO_TRANSFER_UNKNOWN: unknown transfer function
  62. * @GST_VIDEO_TRANSFER_GAMMA10: linear RGB, gamma 1.0 curve
  63. * @GST_VIDEO_TRANSFER_GAMMA18: Gamma 1.8 curve
  64. * @GST_VIDEO_TRANSFER_GAMMA20: Gamma 2.0 curve
  65. * @GST_VIDEO_TRANSFER_GAMMA22: Gamma 2.2 curve
  66. * @GST_VIDEO_TRANSFER_BT709: Gamma 2.2 curve with a linear segment in the lower
  67. * range
  68. * @GST_VIDEO_TRANSFER_SMPTE240M: Gamma 2.2 curve with a linear segment in the
  69. * lower range
  70. * @GST_VIDEO_TRANSFER_SRGB: Gamma 2.4 curve with a linear segment in the lower
  71. * range
  72. * @GST_VIDEO_TRANSFER_GAMMA28: Gamma 2.8 curve
  73. * @GST_VIDEO_TRANSFER_LOG100: Logarithmic transfer characteristic
  74. * 100:1 range
  75. * @GST_VIDEO_TRANSFER_LOG316: Logarithmic transfer characteristic
  76. * 316.22777:1 range
  77. *
  78. * The video transfer function defines the formula for converting between
  79. * non-linear RGB (R'G'B') and linear RGB
  80. */
  81. typedef enum {
  82. GST_VIDEO_TRANSFER_UNKNOWN = 0,
  83. GST_VIDEO_TRANSFER_GAMMA10,
  84. GST_VIDEO_TRANSFER_GAMMA18,
  85. GST_VIDEO_TRANSFER_GAMMA20,
  86. GST_VIDEO_TRANSFER_GAMMA22,
  87. GST_VIDEO_TRANSFER_BT709,
  88. GST_VIDEO_TRANSFER_SMPTE240M,
  89. GST_VIDEO_TRANSFER_SRGB,
  90. GST_VIDEO_TRANSFER_GAMMA28,
  91. GST_VIDEO_TRANSFER_LOG100,
  92. GST_VIDEO_TRANSFER_LOG316
  93. } GstVideoTransferFunction;
  94. /**
  95. * GstVideoColorPrimaries:
  96. * @GST_VIDEO_COLOR_PRIMARIES_UNKNOWN: unknown color primaries
  97. * @GST_VIDEO_COLOR_PRIMARIES_BT709: BT709 primaries
  98. * @GST_VIDEO_COLOR_PRIMARIES_BT470M: BT470M primaries
  99. * @GST_VIDEO_COLOR_PRIMARIES_BT470BG: BT470BG primaries
  100. * @GST_VIDEO_COLOR_PRIMARIES_SMPTE170M: SMPTE170M primaries
  101. * @GST_VIDEO_COLOR_PRIMARIES_SMPTE240M: SMPTE240M primaries
  102. * @GST_VIDEO_COLOR_PRIMARIES_FILM: Generic film
  103. *
  104. * The color primaries define the how to transform linear RGB values to and from
  105. * the CIE XYZ colorspace.
  106. */
  107. typedef enum {
  108. GST_VIDEO_COLOR_PRIMARIES_UNKNOWN = 0,
  109. GST_VIDEO_COLOR_PRIMARIES_BT709,
  110. GST_VIDEO_COLOR_PRIMARIES_BT470M,
  111. GST_VIDEO_COLOR_PRIMARIES_BT470BG,
  112. GST_VIDEO_COLOR_PRIMARIES_SMPTE170M,
  113. GST_VIDEO_COLOR_PRIMARIES_SMPTE240M,
  114. GST_VIDEO_COLOR_PRIMARIES_FILM
  115. } GstVideoColorPrimaries;
  116. /**
  117. * GstVideoColorimetry:
  118. * @range: the color range. This is the valid range for the samples.
  119. * It is used to convert the samples to Y'PbPr values.
  120. * @matrix: the color matrix. Used to convert between Y'PbPr and
  121. * non-linear RGB (R'G'B')
  122. * @transfer: the transfer function. used to convert between R'G'B' and RGB
  123. * @primaries: color primaries. used to convert between R'G'B' and CIE XYZ
  124. *
  125. * Structure describing the color info.
  126. */
  127. typedef struct {
  128. GstVideoColorRange range;
  129. GstVideoColorMatrix matrix;
  130. GstVideoTransferFunction transfer;
  131. GstVideoColorPrimaries primaries;
  132. } GstVideoColorimetry;
  133. /* predefined colorimetry */
  134. #define GST_VIDEO_COLORIMETRY_BT601 "bt601"
  135. #define GST_VIDEO_COLORIMETRY_BT709 "bt709"
  136. #define GST_VIDEO_COLORIMETRY_SMPTE240M "smpte240m"
  137. gboolean gst_video_colorimetry_matches (GstVideoColorimetry *cinfo, const gchar *color);
  138. gboolean gst_video_colorimetry_from_string (GstVideoColorimetry *cinfo, const gchar *color);
  139. gchar * gst_video_colorimetry_to_string (GstVideoColorimetry *cinfo);
  140. /* compute offset and scale */
  141. void gst_video_color_range_offsets (GstVideoColorRange range,
  142. const GstVideoFormatInfo *info,
  143. gint offset[GST_VIDEO_MAX_COMPONENTS],
  144. gint scale[GST_VIDEO_MAX_COMPONENTS]);
  145. G_END_DECLS
  146. #endif /* __GST_VIDEO_COLOR_H__ */