OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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 #include "media/video/half_float_maker_xor.h" |
| 6 |
| 7 namespace media { |
| 8 |
| 9 HalfFloatMaker_xor::HalfFloatMaker_xor(int bits_per_channel) |
| 10 : bits_per_channel_(bits_per_channel) {} |
| 11 |
| 12 float HalfFloatMaker_xor::Multiplier() const { |
| 13 int max_input_value = (1 << bits_per_channel_) - 1; |
| 14 // 2 << 11 = 2048 would be 1.0 with our exponent. |
| 15 return 2048.0 / max_input_value; |
| 16 } |
| 17 |
| 18 float HalfFloatMaker_xor::Offset() const { |
| 19 return 0.5; |
| 20 } |
| 21 |
| 22 void HalfFloatMaker_xor::MakeHalfFloats(const uint16_t* src, |
| 23 size_t num, |
| 24 uint16_t* dst) { |
| 25 // Micro-benchmarking indicates that the compiler does |
| 26 // a good enough job of optimizing this loop that trying |
| 27 // to manually operate on one uint64 at a time is not |
| 28 // actually helpful. |
| 29 // Note to future optimizers: Benchmark your optimizations! |
| 30 for (size_t i = 0; i < num; i++) |
| 31 dst[i] = src[i] | 0x3800; |
| 32 } |
| 33 |
| 34 } // namespace media |
OLD | NEW |