hdr_util.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. // disable deprecation warnings for auto_ptr
  41. #if defined(__GNUC__) && __GNUC__ >= 5
  42. #pragma GCC diagnostic push
  43. #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
  44. #endif
  45. typedef std::auto_ptr<mkvmuxer::PrimaryChromaticity> PrimaryChromaticityPtr;
  46. #if defined(__GNUC__) && __GNUC__ >= 5
  47. #pragma GCC diagnostic pop
  48. #endif
  49. bool CopyPrimaryChromaticity(const mkvparser::PrimaryChromaticity& parser_pc,
  50. PrimaryChromaticityPtr* muxer_pc);
  51. bool MasteringMetadataValuePresent(double value);
  52. bool CopyMasteringMetadata(const mkvparser::MasteringMetadata& parser_mm,
  53. mkvmuxer::MasteringMetadata* muxer_mm);
  54. bool ColourValuePresent(long long value);
  55. bool CopyColour(const mkvparser::Colour& parser_colour,
  56. mkvmuxer::Colour* muxer_colour);
  57. // Returns true if |features| is set to one or more valid values.
  58. bool ParseVpxCodecPrivate(const uint8_t* private_data, int32_t length,
  59. Vp9CodecFeatures* features);
  60. } // namespace libwebm
  61. #endif // LIBWEBM_COMMON_HDR_UTIL_H_