File: hdr_static_metadata.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (76 lines) | stat: -rw-r--r-- 2,761 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_GFX_HDR_STATIC_METADATA_H_
#define UI_GFX_HDR_STATIC_METADATA_H_

#include <cstdint>
#include <vector>

#include "base/numerics/safe_conversions.h"
#include "ui/gfx/color_space_export.h"

namespace gfx {

// This structure is used to define the HDR static capabilities of a display.
// Reflects CEA 861.G-2018, Sec.7.5.13, "HDR Static Metadata Data Block"
// A value of 0.0 in any of the fields means that it's not indicated.
struct COLOR_SPACE_EXPORT HDRStaticMetadata {
  // See Table 43 Data Byte 1 - Electro-Optical Transfer Function
  enum class Eotf {
    // "If “Traditional Gamma - SDR Luminance Range” is indicated, then the
    // maximum encoded luminance is typically mastered to 100 cd/m2"
    kGammaSdrRange = 0,
    // "If “Traditional Gamma – HDR Luminance Range” is indicated, then the
    // maximum encoded luminance is understood to be the maximum luminance of
    // the Sink device."
    kGammaHdrRange = 1,
    kPq = 2,
    kHlg = 3,
  };

  // "Desired Content Max Luminance Data. This is the content’s absolute peak
  // luminance (in cd/m2) (likely only in a small area of the screen) that the
  // display prefers for optimal content rendering."
  double max;
  // "Desired Content Max Frame-average Luminance. This is the content’s max
  // frame-average luminance (in cd/m2) that the display prefers for optimal
  // content rendering."
  double max_avg;
  // "Desired Content Min Luminance. This is the minimum value of the content
  // (in cd/m2) that the display prefers for optimal content rendering."
  double min;
  // "Electro-Optical Transfer Functions supported by the Sink." See Table 85
  // Supported Electro-Optical Transfer Function.
  uint8_t supported_eotf_mask;

  HDRStaticMetadata();
  HDRStaticMetadata(double max,
                    double max_avg,
                    double min,
                    uint8_t supported_eotf_mask);
  HDRStaticMetadata(const HDRStaticMetadata& rhs);
  HDRStaticMetadata& operator=(const HDRStaticMetadata& rhs);

  bool operator==(const HDRStaticMetadata& rhs) const {
    return ((max == rhs.max) && (max_avg == rhs.max_avg) && (min == rhs.min) &&
            supported_eotf_mask == rhs.supported_eotf_mask);
  }

  bool IsEotfSupported(Eotf eotf) const {
    return (supported_eotf_mask & EotfMask({eotf})) != 0;
  }

  static uint8_t EotfMask(std::vector<Eotf> eotfs) {
    int eotf_mask = 0;
    for (const Eotf eotf : eotfs) {
      eotf_mask |= (1 << static_cast<int>(eotf));
    }
    return base::checked_cast<uint8_t>(eotf_mask);
  }
};

}  // namespace gfx

#endif  // UI_GFX_HDR_STATIC_METADATA_H_