hdr_dynamic_vivid_metadata.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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. * HDR Vivid three spline params.
  26. */
  27. typedef struct AVHDRVivid3SplineParams {
  28. /**
  29. * The mode of three Spline. the value shall be in the range
  30. * of 0 to 3, inclusive.
  31. */
  32. int th_mode;
  33. /**
  34. * three_Spline_TH_enable_MB is in the range of 0.0 to 1.0, inclusive
  35. * and in multiples of 1.0/255.
  36. *
  37. */
  38. AVRational th_enable_mb;
  39. /**
  40. * 3Spline_TH_enable of three Spline.
  41. * The value shall be in the range of 0.0 to 1.0, inclusive.
  42. * and in multiples of 1.0/4095.
  43. */
  44. AVRational th_enable;
  45. /**
  46. * 3Spline_TH_Delta1 of three Spline.
  47. * The value shall be in the range of 0.0 to 0.25, inclusive,
  48. * and in multiples of 0.25/1023.
  49. */
  50. AVRational th_delta1;
  51. /**
  52. * 3Spline_TH_Delta2 of three Spline.
  53. * The value shall be in the range of 0.0 to 0.25, inclusive,
  54. * and in multiples of 0.25/1023.
  55. */
  56. AVRational th_delta2;
  57. /**
  58. * 3Spline_enable_Strength of three Spline.
  59. * The value shall be in the range of 0.0 to 1.0, inclusive,
  60. * and in multiples of 1.0/255.
  61. */
  62. AVRational enable_strength;
  63. } AVHDRVivid3SplineParams;
  64. /**
  65. * Color tone mapping parameters at a processing window in a dynamic metadata for
  66. * CUVA 005.1:2021.
  67. */
  68. typedef struct AVHDRVividColorToneMappingParams {
  69. /**
  70. * The nominal maximum display luminance of the targeted system display,
  71. * in multiples of 1.0/4095 candelas per square metre. The value shall be in
  72. * the range of 0.0 to 1.0, inclusive.
  73. */
  74. AVRational targeted_system_display_maximum_luminance;
  75. /**
  76. * This flag indicates that transfer the base paramter(for value of 1)
  77. */
  78. int base_enable_flag;
  79. /**
  80. * base_param_m_p in the base parameter,
  81. * in multiples of 1.0/16383. The value shall be in
  82. * the range of 0.0 to 1.0, inclusive.
  83. */
  84. AVRational base_param_m_p;
  85. /**
  86. * base_param_m_m in the base parameter,
  87. * in multiples of 1.0/10. The value shall be in
  88. * the range of 0.0 to 6.3, inclusive.
  89. */
  90. AVRational base_param_m_m;
  91. /**
  92. * base_param_m_a in the base parameter,
  93. * in multiples of 1.0/1023. The value shall be in
  94. * the range of 0.0 to 1.0 inclusive.
  95. */
  96. AVRational base_param_m_a;
  97. /**
  98. * base_param_m_b in the base parameter,
  99. * in multiples of 1/1023. The value shall be in
  100. * the range of 0.0 to 1.0, inclusive.
  101. */
  102. AVRational base_param_m_b;
  103. /**
  104. * base_param_m_n in the base parameter,
  105. * in multiples of 1.0/10. The value shall be in
  106. * the range of 0.0 to 6.3, inclusive.
  107. */
  108. AVRational base_param_m_n;
  109. /**
  110. * indicates k1_0 in the base parameter,
  111. * base_param_k1 <= 1: k1_0 = base_param_k1
  112. * base_param_k1 > 1: reserved
  113. */
  114. int base_param_k1;
  115. /**
  116. * indicates k2_0 in the base parameter,
  117. * base_param_k2 <= 1: k2_0 = base_param_k2
  118. * base_param_k2 > 1: reserved
  119. */
  120. int base_param_k2;
  121. /**
  122. * indicates k3_0 in the base parameter,
  123. * base_param_k3 == 1: k3_0 = base_param_k3
  124. * base_param_k3 == 2: k3_0 = maximum_maxrgb
  125. * base_param_k3 > 2: reserved
  126. */
  127. int base_param_k3;
  128. /**
  129. * This flag indicates that delta mode of base paramter(for value of 1)
  130. */
  131. int base_param_Delta_enable_mode;
  132. /**
  133. * base_param_Delta in the base parameter,
  134. * in multiples of 1.0/127. The value shall be in
  135. * the range of 0.0 to 1.0, inclusive.
  136. */
  137. AVRational base_param_Delta;
  138. /**
  139. * indicates 3Spline_enable_flag in the base parameter,
  140. * This flag indicates that transfer three Spline of base paramter(for value of 1)
  141. */
  142. int three_Spline_enable_flag;
  143. /**
  144. * The number of three Spline. The value shall be in the range
  145. * of 1 to 2, inclusive.
  146. */
  147. int three_Spline_num;
  148. #if FF_API_HDR_VIVID_THREE_SPLINE
  149. /**
  150. * The mode of three Spline. the value shall be in the range
  151. * of 0 to 3, inclusive.
  152. * @deprecated Use three_spline instead
  153. */
  154. attribute_deprecated
  155. int three_Spline_TH_mode;
  156. /**
  157. * three_Spline_TH_enable_MB is in the range of 0.0 to 1.0, inclusive
  158. * and in multiples of 1.0/255.
  159. * @deprecated Use three_spline instead
  160. */
  161. attribute_deprecated
  162. AVRational three_Spline_TH_enable_MB;
  163. /**
  164. * 3Spline_TH_enable of three Spline.
  165. * The value shall be in the range of 0.0 to 1.0, inclusive.
  166. * and in multiples of 1.0/4095.
  167. * @deprecated Use three_spline instead
  168. */
  169. attribute_deprecated
  170. AVRational three_Spline_TH_enable;
  171. /**
  172. * 3Spline_TH_Delta1 of three Spline.
  173. * The value shall be in the range of 0.0 to 0.25, inclusive,
  174. * and in multiples of 0.25/1023.
  175. * @deprecated Use three_spline instead
  176. */
  177. attribute_deprecated
  178. AVRational three_Spline_TH_Delta1;
  179. /**
  180. * 3Spline_TH_Delta2 of three Spline.
  181. * The value shall be in the range of 0.0 to 0.25, inclusive,
  182. * and in multiples of 0.25/1023.
  183. * @deprecated Use three_spline instead
  184. */
  185. attribute_deprecated
  186. AVRational three_Spline_TH_Delta2;
  187. /**
  188. * 3Spline_enable_Strength of three Spline.
  189. * The value shall be in the range of 0.0 to 1.0, inclusive,
  190. * and in multiples of 1.0/255.
  191. * @deprecated Use three_spline instead
  192. */
  193. attribute_deprecated
  194. AVRational three_Spline_enable_Strength;
  195. #endif
  196. AVHDRVivid3SplineParams three_spline[2];
  197. } AVHDRVividColorToneMappingParams;
  198. /**
  199. * Color transform parameters at a processing window in a dynamic metadata for
  200. * CUVA 005.1:2021.
  201. */
  202. typedef struct AVHDRVividColorTransformParams {
  203. /**
  204. * Indicates the minimum brightness of the displayed content.
  205. * The values should be in the range of 0.0 to 1.0,
  206. * inclusive and in multiples of 1/4095.
  207. */
  208. AVRational minimum_maxrgb;
  209. /**
  210. * Indicates the average brightness of the displayed content.
  211. * The values should be in the range of 0.0 to 1.0,
  212. * inclusive and in multiples of 1/4095.
  213. */
  214. AVRational average_maxrgb;
  215. /**
  216. * Indicates the variance brightness of the displayed content.
  217. * The values should be in the range of 0.0 to 1.0,
  218. * inclusive and in multiples of 1/4095.
  219. */
  220. AVRational variance_maxrgb;
  221. /**
  222. * Indicates the maximum brightness of the displayed content.
  223. * The values should be in the range of 0.0 to 1.0, inclusive
  224. * and in multiples of 1/4095.
  225. */
  226. AVRational maximum_maxrgb;
  227. /**
  228. * This flag indicates that the metadata for the tone mapping function in
  229. * the processing window is present (for value of 1).
  230. */
  231. int tone_mapping_mode_flag;
  232. /**
  233. * The number of tone mapping param. The value shall be in the range
  234. * of 1 to 2, inclusive.
  235. */
  236. int tone_mapping_param_num;
  237. /**
  238. * The color tone mapping parameters.
  239. */
  240. AVHDRVividColorToneMappingParams tm_params[2];
  241. /**
  242. * This flag indicates that the metadata for the color saturation mapping in
  243. * the processing window is present (for value of 1).
  244. */
  245. int color_saturation_mapping_flag;
  246. /**
  247. * The number of color saturation param. The value shall be in the range
  248. * of 0 to 7, inclusive.
  249. */
  250. int color_saturation_num;
  251. /**
  252. * Indicates the color correction strength parameter.
  253. * The values should be in the range of 0.0 to 2.0, inclusive
  254. * and in multiples of 1/128.
  255. */
  256. AVRational color_saturation_gain[8];
  257. } AVHDRVividColorTransformParams;
  258. /**
  259. * This struct represents dynamic metadata for color volume transform -
  260. * CUVA 005.1:2021 standard
  261. *
  262. * To be used as payload of a AVFrameSideData or AVPacketSideData with the
  263. * appropriate type.
  264. *
  265. * @note The struct should be allocated with
  266. * av_dynamic_hdr_vivid_alloc() and its size is not a part of
  267. * the public ABI.
  268. */
  269. typedef struct AVDynamicHDRVivid {
  270. /**
  271. * The system start code. The value shall be set to 0x01.
  272. */
  273. uint8_t system_start_code;
  274. /**
  275. * The number of processing windows. The value shall be set to 0x01
  276. * if the system_start_code is 0x01.
  277. */
  278. uint8_t num_windows;
  279. /**
  280. * The color transform parameters for every processing window.
  281. */
  282. AVHDRVividColorTransformParams params[3];
  283. } AVDynamicHDRVivid;
  284. /**
  285. * Allocate an AVDynamicHDRVivid structure and set its fields to
  286. * default values. The resulting struct can be freed using av_freep().
  287. *
  288. * @return An AVDynamicHDRVivid filled with default values or NULL
  289. * on failure.
  290. */
  291. AVDynamicHDRVivid *av_dynamic_hdr_vivid_alloc(size_t *size);
  292. /**
  293. * Allocate a complete AVDynamicHDRVivid and add it to the frame.
  294. * @param frame The frame which side data is added to.
  295. *
  296. * @return The AVDynamicHDRVivid structure to be filled by caller or NULL
  297. * on failure.
  298. */
  299. AVDynamicHDRVivid *av_dynamic_hdr_vivid_create_side_data(AVFrame *frame);
  300. #endif /* AVUTIL_HDR_DYNAMIC_VIVID_METADATA_H */