| Index: media/video/half_float_maker_lib_yuv.cc
|
| diff --git a/media/video/half_float_maker_lib_yuv.cc b/media/video/half_float_maker_lib_yuv.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..dc3f90047689e9455c20324068b34225e0f9068d
|
| --- /dev/null
|
| +++ b/media/video/half_float_maker_lib_yuv.cc
|
| @@ -0,0 +1,45 @@
|
| +// Copyright (c) 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/video/half_float_maker_lib_yuv.h"
|
| +#include "third_party/libyuv/include/libyuv.h"
|
| +
|
| +namespace media {
|
| +
|
| +HalfFloatMaker_libyuv::HalfFloatMaker_libyuv(int bits_per_channel) {
|
| + int max_value = (1 << bits_per_channel) - 1;
|
| + // For less than 15 bits, we can give libyuv a multiplier of
|
| + // 1.0, which is faster on some platforms. If bits is 16 or larger,
|
| + // a multiplier of 1.0 would cause overflows. However, a multiplier
|
| + // of 1/max_value would cause subnormal floats, which perform
|
| + // very poorly on some platforms.
|
| + if (bits_per_channel <= 15) {
|
| + libyuv_multiplier_ = 1.0f;
|
| + } else {
|
| + // This multiplier makes sure that we avoid subnormal values.
|
| + libyuv_multiplier_ = 1.0f / 4096.0f;
|
| + }
|
| + resource_multiplier_ = 1.0f / libyuv_multiplier_ / max_value;
|
| +}
|
| +
|
| +float HalfFloatMaker_libyuv::Offset() const {
|
| + return 0.5;
|
| +}
|
| +
|
| +float HalfFloatMaker_libyuv::Multiplier() const {
|
| + return resource_multiplier_;
|
| +}
|
| +
|
| +void HalfFloatMaker_libyuv::MakeHalfFloats(const uint16_t* src,
|
| + size_t num,
|
| + uint16_t* dst) {
|
| + // Source and dest stride can be zero since we're only copying
|
| + // one row at a time.
|
| + int stride = 0;
|
| + int rows = 1;
|
| + libyuv::HalfFloatPlane(src, stride, dst, stride, libyuv_multiplier_, num,
|
| + rows);
|
| +}
|
| +
|
| +} // namespace media
|
|
|