xref: /aosp_15_r20/external/libwebm/common/hdr_util.h (revision 103e46e4cd4b6efcf6001f23fa8665fb110abf8d)
1*103e46e4SHarish Mahendrakar // Copyright (c) 2016 The WebM project authors. All Rights Reserved.
2*103e46e4SHarish Mahendrakar //
3*103e46e4SHarish Mahendrakar // Use of this source code is governed by a BSD-style license
4*103e46e4SHarish Mahendrakar // that can be found in the LICENSE file in the root of the source
5*103e46e4SHarish Mahendrakar // tree. An additional intellectual property rights grant can be found
6*103e46e4SHarish Mahendrakar // in the file PATENTS.  All contributing project authors may
7*103e46e4SHarish Mahendrakar // be found in the AUTHORS file in the root of the source tree.
8*103e46e4SHarish Mahendrakar #ifndef LIBWEBM_COMMON_HDR_UTIL_H_
9*103e46e4SHarish Mahendrakar #define LIBWEBM_COMMON_HDR_UTIL_H_
10*103e46e4SHarish Mahendrakar 
11*103e46e4SHarish Mahendrakar #include <stdint.h>
12*103e46e4SHarish Mahendrakar 
13*103e46e4SHarish Mahendrakar #include <memory>
14*103e46e4SHarish Mahendrakar 
15*103e46e4SHarish Mahendrakar #include "mkvmuxer/mkvmuxer.h"
16*103e46e4SHarish Mahendrakar 
17*103e46e4SHarish Mahendrakar namespace mkvparser {
18*103e46e4SHarish Mahendrakar struct Colour;
19*103e46e4SHarish Mahendrakar struct MasteringMetadata;
20*103e46e4SHarish Mahendrakar struct PrimaryChromaticity;
21*103e46e4SHarish Mahendrakar }  // namespace mkvparser
22*103e46e4SHarish Mahendrakar 
23*103e46e4SHarish Mahendrakar namespace libwebm {
24*103e46e4SHarish Mahendrakar // Utility types and functions for working with the Colour element and its
25*103e46e4SHarish Mahendrakar // children. Copiers return true upon success. Presence functions return true
26*103e46e4SHarish Mahendrakar // when the specified element is present.
27*103e46e4SHarish Mahendrakar 
28*103e46e4SHarish Mahendrakar // TODO(tomfinegan): These should be moved to libwebm_utils once c++11 is
29*103e46e4SHarish Mahendrakar // required by libwebm.
30*103e46e4SHarish Mahendrakar 
31*103e46e4SHarish Mahendrakar // Features of the VP9 codec that may be set in the CodecPrivate of a VP9 video
32*103e46e4SHarish Mahendrakar // stream. A value of kValueNotPresent represents that the value was not set in
33*103e46e4SHarish Mahendrakar // the CodecPrivate.
34*103e46e4SHarish Mahendrakar struct Vp9CodecFeatures {
35*103e46e4SHarish Mahendrakar   static const int kValueNotPresent;
36*103e46e4SHarish Mahendrakar 
Vp9CodecFeaturesVp9CodecFeatures37*103e46e4SHarish Mahendrakar   Vp9CodecFeatures()
38*103e46e4SHarish Mahendrakar       : profile(kValueNotPresent),
39*103e46e4SHarish Mahendrakar         level(kValueNotPresent),
40*103e46e4SHarish Mahendrakar         bit_depth(kValueNotPresent),
41*103e46e4SHarish Mahendrakar         chroma_subsampling(kValueNotPresent) {}
~Vp9CodecFeaturesVp9CodecFeatures42*103e46e4SHarish Mahendrakar   ~Vp9CodecFeatures() {}
43*103e46e4SHarish Mahendrakar 
44*103e46e4SHarish Mahendrakar   int profile;
45*103e46e4SHarish Mahendrakar   int level;
46*103e46e4SHarish Mahendrakar   int bit_depth;
47*103e46e4SHarish Mahendrakar   int chroma_subsampling;
48*103e46e4SHarish Mahendrakar };
49*103e46e4SHarish Mahendrakar 
50*103e46e4SHarish Mahendrakar typedef std::unique_ptr<mkvmuxer::PrimaryChromaticity> PrimaryChromaticityPtr;
51*103e46e4SHarish Mahendrakar 
52*103e46e4SHarish Mahendrakar bool CopyPrimaryChromaticity(const mkvparser::PrimaryChromaticity& parser_pc,
53*103e46e4SHarish Mahendrakar                              PrimaryChromaticityPtr* muxer_pc);
54*103e46e4SHarish Mahendrakar 
55*103e46e4SHarish Mahendrakar bool MasteringMetadataValuePresent(double value);
56*103e46e4SHarish Mahendrakar 
57*103e46e4SHarish Mahendrakar bool CopyMasteringMetadata(const mkvparser::MasteringMetadata& parser_mm,
58*103e46e4SHarish Mahendrakar                            mkvmuxer::MasteringMetadata* muxer_mm);
59*103e46e4SHarish Mahendrakar 
60*103e46e4SHarish Mahendrakar bool ColourValuePresent(long long value);
61*103e46e4SHarish Mahendrakar 
62*103e46e4SHarish Mahendrakar bool CopyColour(const mkvparser::Colour& parser_colour,
63*103e46e4SHarish Mahendrakar                 mkvmuxer::Colour* muxer_colour);
64*103e46e4SHarish Mahendrakar 
65*103e46e4SHarish Mahendrakar // Returns true if |features| is set to one or more valid values.
66*103e46e4SHarish Mahendrakar bool ParseVpxCodecPrivate(const uint8_t* private_data, int32_t length,
67*103e46e4SHarish Mahendrakar                           Vp9CodecFeatures* features);
68*103e46e4SHarish Mahendrakar 
69*103e46e4SHarish Mahendrakar }  // namespace libwebm
70*103e46e4SHarish Mahendrakar 
71*103e46e4SHarish Mahendrakar #endif  // LIBWEBM_COMMON_HDR_UTIL_H_
72