hdr_dynamic_vivid_metadata.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. /*
  2. * Copyright (c) 2021 Limin Wang <lance.lmwang at gmail.com>
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef AVUTIL_HDR_DYNAMIC_VIVID_METADATA_H
  21. #define AVUTIL_HDR_DYNAMIC_VIVID_METADATA_H
  22. #include "frame.h"
  23. #include "rational.h"
  24. /**
  25. * Color tone mapping parameters at a processing window in a dynamic metadata for
  26. * CUVA 005.1:2021.
  27. */
  28. typedef struct AVHDRVividColorToneMappingParams {
  29. /**
  30. * The nominal maximum display luminance of the targeted system display,
  31. * in multiples of 1.0/4095 candelas per square metre. The value shall be in
  32. * the range of 0.0 to 1.0, inclusive.
  33. */
  34. AVRational targeted_system_display_maximum_luminance;
  35. /**
  36. * This flag indicates that transfer the base paramter(for value of 1)
  37. */
  38. int base_enable_flag;
  39. /**
  40. * base_param_m_p in the base parameter,
  41. * in multiples of 1.0/16383. The value shall be in
  42. * the range of 0.0 to 1.0, inclusive.
  43. */
  44. AVRational base_param_m_p;
  45. /**
  46. * base_param_m_m in the base parameter,
  47. * in multiples of 1.0/10. The value shall be in
  48. * the range of 0.0 to 6.3, inclusive.
  49. */
  50. AVRational base_param_m_m;
  51. /**
  52. * base_param_m_a in the base parameter,
  53. * in multiples of 1.0/1023. The value shall be in
  54. * the range of 0.0 to 1.0 inclusive.
  55. */
  56. AVRational base_param_m_a;
  57. /**
  58. * base_param_m_b in the base parameter,
  59. * in multiples of 1/1023. The value shall be in
  60. * the range of 0.0 to 1.0, inclusive.
  61. */
  62. AVRational base_param_m_b;
  63. /**
  64. * base_param_m_n in the base parameter,
  65. * in multiples of 1.0/10. The value shall be in
  66. * the range of 0.0 to 6.3, inclusive.
  67. */
  68. AVRational base_param_m_n;
  69. /**
  70. * indicates k1_0 in the base parameter,
  71. * base_param_k1 <= 1: k1_0 = base_param_k1
  72. * base_param_k1 > 1: reserved
  73. */
  74. int base_param_k1;
  75. /**
  76. * indicates k2_0 in the base parameter,
  77. * base_param_k2 <= 1: k2_0 = base_param_k2
  78. * base_param_k2 > 1: reserved
  79. */
  80. int base_param_k2;
  81. /**
  82. * indicates k3_0 in the base parameter,
  83. * base_param_k3 == 1: k3_0 = base_param_k3
  84. * base_param_k3 == 2: k3_0 = maximum_maxrgb
  85. * base_param_k3 > 2: reserved
  86. */
  87. int base_param_k3;
  88. /**
  89. * This flag indicates that delta mode of base paramter(for value of 1)
  90. */
  91. int base_param_Delta_enable_mode;
  92. /**
  93. * base_param_Delta in the base parameter,
  94. * in multiples of 1.0/127. The value shall be in
  95. * the range of 0.0 to 1.0, inclusive.
  96. */
  97. AVRational base_param_Delta;
  98. /**
  99. * indicates 3Spline_enable_flag in the base parameter,
  100. * This flag indicates that transfer three Spline of base paramter(for value of 1)
  101. */
  102. int three_Spline_enable_flag;
  103. /**
  104. * The number of three Spline. The value shall be in the range
  105. * of 1 to 2, inclusive.
  106. */
  107. int three_Spline_num;
  108. /**
  109. * The mode of three Spline. the value shall be in the range
  110. * of 0 to 3, inclusive.
  111. */
  112. int three_Spline_TH_mode;
  113. /**
  114. * three_Spline_TH_enable_MB is in the range of 0.0 to 1.0, inclusive
  115. * and in multiples of 1.0/255.
  116. *
  117. */
  118. AVRational three_Spline_TH_enable_MB;
  119. /**
  120. * 3Spline_TH_enable of three Spline.
  121. * The value shall be in the range of 0.0 to 1.0, inclusive.
  122. * and in multiples of 1.0/4095.
  123. */
  124. AVRational three_Spline_TH_enable;
  125. /**
  126. * 3Spline_TH_Delta1 of three Spline.
  127. * The value shall be in the range of 0.0 to 0.25, inclusive,
  128. * and in multiples of 0.25/1023.
  129. */
  130. AVRational three_Spline_TH_Delta1;
  131. /**
  132. * 3Spline_TH_Delta2 of three Spline.
  133. * The value shall be in the range of 0.0 to 0.25, inclusive,
  134. * and in multiples of 0.25/1023.
  135. */
  136. AVRational three_Spline_TH_Delta2;
  137. /**
  138. * 3Spline_enable_Strength of three Spline.
  139. * The value shall be in the range of 0.0 to 1.0, inclusive,
  140. * and in multiples of 1.0/255.
  141. */
  142. AVRational three_Spline_enable_Strength;
  143. } AVHDRVividColorToneMappingParams;
  144. /**
  145. * Color transform parameters at a processing window in a dynamic metadata for
  146. * CUVA 005.1:2021.
  147. */
  148. typedef struct AVHDRVividColorTransformParams {
  149. /**
  150. * Indicates the minimum brightness of the displayed content.
  151. * The values should be in the range of 0.0 to 1.0,
  152. * inclusive and in multiples of 1/4095.
  153. */
  154. AVRational minimum_maxrgb;
  155. /**
  156. * Indicates the average brightness of the displayed content.
  157. * The values should be in the range of 0.0 to 1.0,
  158. * inclusive and in multiples of 1/4095.
  159. */
  160. AVRational average_maxrgb;
  161. /**
  162. * Indicates the variance brightness of the displayed content.
  163. * The values should be in the range of 0.0 to 1.0,
  164. * inclusive and in multiples of 1/4095.
  165. */
  166. AVRational variance_maxrgb;
  167. /**
  168. * Indicates the maximum brightness of the displayed content.
  169. * The values should be in the range of 0.0 to 1.0, inclusive
  170. * and in multiples of 1/4095.
  171. */
  172. AVRational maximum_maxrgb;
  173. /**
  174. * This flag indicates that the metadata for the tone mapping function in
  175. * the processing window is present (for value of 1).
  176. */
  177. int tone_mapping_mode_flag;
  178. /**
  179. * The number of tone mapping param. The value shall be in the range
  180. * of 1 to 2, inclusive.
  181. */
  182. int tone_mapping_param_num;
  183. /**
  184. * The color tone mapping parameters.
  185. */
  186. AVHDRVividColorToneMappingParams tm_params[2];
  187. /**
  188. * This flag indicates that the metadata for the color saturation mapping in
  189. * the processing window is present (for value of 1).
  190. */
  191. int color_saturation_mapping_flag;
  192. /**
  193. * The number of color saturation param. The value shall be in the range
  194. * of 0 to 7, inclusive.
  195. */
  196. int color_saturation_num;
  197. /**
  198. * Indicates the color correction strength parameter.
  199. * The values should be in the range of 0.0 to 2.0, inclusive
  200. * and in multiples of 1/128.
  201. */
  202. AVRational color_saturation_gain[8];
  203. } AVHDRVividColorTransformParams;
  204. /**
  205. * This struct represents dynamic metadata for color volume transform -
  206. * CUVA 005.1:2021 standard
  207. *
  208. * To be used as payload of a AVFrameSideData or AVPacketSideData with the
  209. * appropriate type.
  210. *
  211. * @note The struct should be allocated with
  212. * av_dynamic_hdr_vivid_alloc() and its size is not a part of
  213. * the public ABI.
  214. */
  215. typedef struct AVDynamicHDRVivid {
  216. /**
  217. * The system start code. The value shall be set to 0x01.
  218. */
  219. uint8_t system_start_code;
  220. /**
  221. * The number of processing windows. The value shall be set to 0x01
  222. * if the system_start_code is 0x01.
  223. */
  224. uint8_t num_windows;
  225. /**
  226. * The color transform parameters for every processing window.
  227. */
  228. AVHDRVividColorTransformParams params[3];
  229. } AVDynamicHDRVivid;
  230. /**
  231. * Allocate an AVDynamicHDRVivid structure and set its fields to
  232. * default values. The resulting struct can be freed using av_freep().
  233. *
  234. * @return An AVDynamicHDRVivid filled with default values or NULL
  235. * on failure.
  236. */
  237. AVDynamicHDRVivid *av_dynamic_hdr_vivid_alloc(size_t *size);
  238. /**
  239. * Allocate a complete AVDynamicHDRVivid and add it to the frame.
  240. * @param frame The frame which side data is added to.
  241. *
  242. * @return The AVDynamicHDRVivid structure to be filled by caller or NULL
  243. * on failure.
  244. */
  245. AVDynamicHDRVivid *av_dynamic_hdr_vivid_create_side_data(AVFrame *frame);
  246. #endif /* AVUTIL_HDR_DYNAMIC_VIVID_METADATA_H */