Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_VIDEO_HALF_FLOAT_MAKER_XOR_H_ | |
| 6 #define MEDIA_VIDEO_HALF_FLOAT_MAKER_XOR_H_ | |
| 7 | |
| 8 #include "media/base/media_export.h" | |
| 9 #include "media/video/half_float_maker.h" | |
| 10 | |
| 11 namespace media { | |
| 12 // By OR-ing with 0x3800, 10-bit numbers become half-floats in the | |
| 13 // range [0.5..1) and 9-bit numbers get the range [0.5..0.75). | |
| 14 // | |
| 15 // Half-floats are evaluated as: | |
| 16 // float value = pow(2.0, exponent - 25) * (0x400 + fraction); | |
| 17 // | |
| 18 // In our case the exponent is 14 (since we or with 0x3800) and | |
| 19 // pow(2.0, 14-25) * 0x400 evaluates to 0.5 (our offset) and | |
| 20 // pow(2.0, 14-25) * fraction is [0..0.49951171875] for 10-bit and | |
| 21 // [0..0.24951171875] for 9-bit. | |
| 22 // | |
| 23 // https://en.wikipedia.org/wiki/Half-precision_floating-point_format | |
| 24 | |
| 25 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.
| |
| 26 public: | |
| 27 explicit HalfFloatMaker_xor(int bits_per_channel); | |
| 28 float Offset() const override; | |
| 29 float Multiplier() const override; | |
| 30 void MakeHalfFloats(const uint16_t* src, size_t num, uint16_t* dst) override; | |
| 31 | |
| 32 private: | |
| 33 int bits_per_channel_; | |
| 34 }; | |
| 35 | |
| 36 } // namespace media | |
| 37 #endif // MEDIA_VIDEO_HALF_FLOAT_MAKER_H_ | |
| OLD | NEW |