hdr_util.h 2.3 KB

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