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 SRC_COLOUR_PARSER_H_
9 #define SRC_COLOUR_PARSER_H_
10 
11 #include "src/int_parser.h"
12 #include "src/master_value_parser.h"
13 #include "src/mastering_metadata_parser.h"
14 #include "webm/dom_types.h"
15 #include "webm/id.h"
16 
17 namespace webm {
18 
19 // Spec reference:
20 // http://matroska.org/technical/specs/index.html#Colour
21 // http://www.webmproject.org/docs/container/#Colour
22 class ColourParser : public MasterValueParser<Colour> {
23  public:
ColourParser()24   ColourParser()
25       : MasterValueParser<Colour>(
26             MakeChild<IntParser<MatrixCoefficients>>(
27                 Id::kMatrixCoefficients, &Colour::matrix_coefficients),
28             MakeChild<UnsignedIntParser>(Id::kBitsPerChannel,
29                                          &Colour::bits_per_channel),
30             MakeChild<UnsignedIntParser>(Id::kChromaSubsamplingHorz,
31                                          &Colour::chroma_subsampling_x),
32             MakeChild<UnsignedIntParser>(Id::kChromaSubsamplingVert,
33                                          &Colour::chroma_subsampling_y),
34             MakeChild<UnsignedIntParser>(Id::kCbSubsamplingHorz,
35                                          &Colour::cb_subsampling_x),
36             MakeChild<UnsignedIntParser>(Id::kCbSubsamplingVert,
37                                          &Colour::cb_subsampling_y),
38             MakeChild<UnsignedIntParser>(Id::kChromaSitingHorz,
39                                          &Colour::chroma_siting_x),
40             MakeChild<UnsignedIntParser>(Id::kChromaSitingVert,
41                                          &Colour::chroma_siting_y),
42             MakeChild<IntParser<Range>>(Id::kRange, &Colour::range),
43             MakeChild<IntParser<TransferCharacteristics>>(
44                 Id::kTransferCharacteristics,
45                 &Colour::transfer_characteristics),
46             MakeChild<IntParser<Primaries>>(Id::kPrimaries, &Colour::primaries),
47             MakeChild<UnsignedIntParser>(Id::kMaxCll, &Colour::max_cll),
48             MakeChild<UnsignedIntParser>(Id::kMaxFall, &Colour::max_fall),
49             MakeChild<MasteringMetadataParser>(Id::kMasteringMetadata,
50                                                &Colour::mastering_metadata)) {}
51 };
52 
53 }  // namespace webm
54 
55 #endif  // SRC_COLOUR_PARSER_H_
56