Chromium Code Reviews| Index: media/video/half_float_maker_xor.h |
| diff --git a/media/video/half_float_maker_xor.h b/media/video/half_float_maker_xor.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e109134349670ff2723bfa91b8e0581983f63259 |
| --- /dev/null |
| +++ b/media/video/half_float_maker_xor.h |
| @@ -0,0 +1,37 @@ |
| +// 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. |
| + |
| +#ifndef MEDIA_VIDEO_HALF_FLOAT_MAKER_XOR_H_ |
| +#define MEDIA_VIDEO_HALF_FLOAT_MAKER_XOR_H_ |
| + |
| +#include "media/base/media_export.h" |
| +#include "media/video/half_float_maker.h" |
| + |
| +namespace media { |
| +// By OR-ing with 0x3800, 10-bit numbers become half-floats in the |
| +// range [0.5..1) and 9-bit numbers get the range [0.5..0.75). |
| +// |
| +// Half-floats are evaluated as: |
| +// float value = pow(2.0, exponent - 25) * (0x400 + fraction); |
| +// |
| +// In our case the exponent is 14 (since we or with 0x3800) and |
| +// pow(2.0, 14-25) * 0x400 evaluates to 0.5 (our offset) and |
| +// pow(2.0, 14-25) * fraction is [0..0.49951171875] for 10-bit and |
| +// [0..0.24951171875] for 9-bit. |
| +// |
| +// https://en.wikipedia.org/wiki/Half-precision_floating-point_format |
| + |
| +class MEDIA_EXPORT HalfFloatMaker_xor : public media::HalfFloatMaker { |
|
hubbe
2017/03/22 17:48:22
I don't think you need to expose this class in a h
Uzair
2017/03/23 07:13:30
Done.
|
| + public: |
| + explicit HalfFloatMaker_xor(int bits_per_channel); |
| + float Offset() const override; |
| + float Multiplier() const override; |
| + void MakeHalfFloats(const uint16_t* src, size_t num, uint16_t* dst) override; |
| + |
| + private: |
| + int bits_per_channel_; |
| +}; |
| + |
| +} // namespace media |
| +#endif // MEDIA_VIDEO_HALF_FLOAT_MAKER_H_ |