Home | History | Annotate | Download | only in common
      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 
     11 #include <stdint.h>
     12 
     13 #include <memory>
     14 
     15 #include "mkvmuxer/mkvmuxer.h"
     16 
     17 namespace mkvparser {
     18 struct Colour;
     19 struct MasteringMetadata;
     20 struct PrimaryChromaticity;
     21 }  // namespace mkvparser
     22 
     23 namespace libwebm {
     24 // Utility types and functions for working with the Colour element and its
     25 // children. Copiers return true upon success. Presence functions return true
     26 // when the specified element is present.
     27 
     28 // TODO(tomfinegan): These should be moved to libwebm_utils once c++11 is
     29 // required by libwebm.
     30 
     31 // Features of the VP9 codec that may be set in the CodecPrivate of a VP9 video
     32 // stream. A value of kValueNotPresent represents that the value was not set in
     33 // the CodecPrivate.
     34 struct Vp9CodecFeatures {
     35   static const int kValueNotPresent;
     36 
     37   Vp9CodecFeatures()
     38       : profile(kValueNotPresent),
     39         level(kValueNotPresent),
     40         bit_depth(kValueNotPresent),
     41         chroma_subsampling(kValueNotPresent) {}
     42   ~Vp9CodecFeatures() {}
     43 
     44   int profile;
     45   int level;
     46   int bit_depth;
     47   int chroma_subsampling;
     48 };
     49 
     50 typedef std::unique_ptr<mkvmuxer::PrimaryChromaticity> PrimaryChromaticityPtr;
     51 
     52 bool CopyPrimaryChromaticity(const mkvparser::PrimaryChromaticity& parser_pc,
     53                              PrimaryChromaticityPtr* muxer_pc);
     54 
     55 bool MasteringMetadataValuePresent(double value);
     56 
     57 bool CopyMasteringMetadata(const mkvparser::MasteringMetadata& parser_mm,
     58                            mkvmuxer::MasteringMetadata* muxer_mm);
     59 
     60 bool ColourValuePresent(long long value);
     61 
     62 bool CopyColour(const mkvparser::Colour& parser_colour,
     63                 mkvmuxer::Colour* muxer_colour);
     64 
     65 // Returns true if |features| is set to one or more valid values.
     66 bool ParseVpxCodecPrivate(const uint8_t* private_data, int32_t length,
     67                           Vp9CodecFeatures* features);
     68 
     69 }  // namespace libwebm
     70 
     71 #endif  // LIBWEBM_COMMON_HDR_UTIL_H_
     72