1 // Copyright 2020 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef UI_GFX_HDR_METADATA_H_ 6 #define UI_GFX_HDR_METADATA_H_ 7 8 #include "ui/gfx/geometry/point_f.h" 9 #include "ui/gfx/gfx_export.h" 10 11 namespace gfx { 12 13 // SMPTE ST 2086 mastering metadata. 14 struct GFX_EXPORT MasteringMetadata { 15 using Chromaticity = PointF; 16 Chromaticity primary_r; 17 Chromaticity primary_g; 18 Chromaticity primary_b; 19 Chromaticity white_point; 20 float luminance_max = 0; 21 float luminance_min = 0; 22 23 MasteringMetadata(); 24 MasteringMetadata(const MasteringMetadata& rhs); 25 26 bool operator==(const MasteringMetadata& rhs) const { 27 return ((primary_r == rhs.primary_r) && (primary_g == rhs.primary_g) && 28 (primary_b == rhs.primary_b) && (white_point == rhs.white_point) && 29 (luminance_max == rhs.luminance_max) && 30 (luminance_min == rhs.luminance_min)); 31 } 32 }; 33 34 // HDR metadata common for HDR10 and WebM/VP9-based HDR formats. 35 struct GFX_EXPORT HDRMetadata { 36 MasteringMetadata mastering_metadata; 37 // Max content light level (CLL), i.e. maximum brightness level present in the 38 // stream), in nits. 39 unsigned max_content_light_level = 0; 40 // Max frame-average light level (FALL), i.e. maximum average brightness of 41 // the brightest frame in the stream), in nits. 42 unsigned max_frame_average_light_level = 0; 43 44 HDRMetadata(); 45 HDRMetadata(const HDRMetadata& rhs); 46 IsValidHDRMetadata47 bool IsValid() const { 48 return !((max_content_light_level == 0) && 49 (max_frame_average_light_level == 0) && 50 (mastering_metadata == MasteringMetadata())); 51 } 52 53 bool operator==(const HDRMetadata& rhs) const { 54 return ( 55 (max_content_light_level == rhs.max_content_light_level) && 56 (max_frame_average_light_level == rhs.max_frame_average_light_level) && 57 (mastering_metadata == rhs.mastering_metadata)); 58 } 59 }; 60 61 // HDR metadata types as described in 62 // https://w3c.github.io/media-capabilities/#enumdef-hdrmetadatatype 63 enum class HdrMetadataType { 64 kNone, 65 kSmpteSt2086, 66 kSmpteSt2094_10, 67 kSmpteSt2094_40, 68 }; 69 70 } // namespace gfx 71 72 #endif // UI_GFX_HDR_METADATA_H_ 73