| Index: media/base/video_color_space.cc
|
| diff --git a/media/base/video_color_space.cc b/media/base/video_color_space.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..0501ec4e12cd6b86e8e5f82aa25b12096f676dfd
|
| --- /dev/null
|
| +++ b/media/base/video_color_space.cc
|
| @@ -0,0 +1,58 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "media/base/video_color_space.h"
|
| +
|
| +namespace media {
|
| +
|
| +VideoColorSpace::PrimaryID VideoColorSpace::GetPrimaryID(int primary) {
|
| + if (primary < 1 || primary > 22 || primary == 3)
|
| + return PrimaryID::INVALID;
|
| + if (primary > 12 && primary < 22)
|
| + return PrimaryID::INVALID;
|
| + return static_cast<PrimaryID>(primary);
|
| +}
|
| +
|
| +VideoColorSpace::TransferID VideoColorSpace::GetTransferID(int transfer) {
|
| + if (transfer < 1 || transfer > 18 || transfer == 3)
|
| + return TransferID::INVALID;
|
| + return static_cast<TransferID>(transfer);
|
| +}
|
| +
|
| +VideoColorSpace::MatrixID VideoColorSpace::GetMatrixID(int matrix) {
|
| + if (matrix < 0 || matrix > 11 || matrix == 3)
|
| + return MatrixID::INVALID;
|
| + return static_cast<MatrixID>(matrix);
|
| +}
|
| +
|
| +VideoColorSpace::VideoColorSpace() {}
|
| +
|
| +VideoColorSpace::VideoColorSpace(PrimaryID primaries,
|
| + TransferID transfer,
|
| + MatrixID matrix,
|
| + gfx::ColorSpace::RangeID range)
|
| + : primaries(primaries), transfer(transfer), matrix(matrix), range(range) {}
|
| +
|
| +VideoColorSpace::VideoColorSpace(int primaries,
|
| + int transfer,
|
| + int matrix,
|
| + gfx::ColorSpace::RangeID range)
|
| + : primaries(GetPrimaryID(primaries)),
|
| + transfer(GetTransferID(transfer)),
|
| + matrix(GetMatrixID(matrix)),
|
| + range(range) {}
|
| +
|
| +gfx::ColorSpace VideoColorSpace::ToGfxColorSpace() const {
|
| + // TODO(hubbe): Make this type-safe.
|
| + return gfx::ColorSpace::CreateVideo(static_cast<int>(primaries),
|
| + static_cast<int>(transfer),
|
| + static_cast<int>(matrix), range);
|
| +}
|
| +
|
| +VideoColorSpace VideoColorSpace::BT709() {
|
| + return VideoColorSpace(PrimaryID::BT709, TransferID::BT709, MatrixID::BT709,
|
| + gfx::ColorSpace::RangeID::LIMITED);
|
| +}
|
| +
|
| +} // namespace
|
|
|