Index: media/video/half_float_maker_xor.cc |
diff --git a/media/video/half_float_maker_xor.cc b/media/video/half_float_maker_xor.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e5dcf1b0a4be2dc6d9a3fcea25671d56797fc64b |
--- /dev/null |
+++ b/media/video/half_float_maker_xor.cc |
@@ -0,0 +1,34 @@ |
+// 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_xor.h" |
+ |
+namespace media { |
+ |
+HalfFloatMaker_xor::HalfFloatMaker_xor(int bits_per_channel) |
+ : bits_per_channel_(bits_per_channel) {} |
+ |
+float HalfFloatMaker_xor::Multiplier() const { |
+ int max_input_value = (1 << bits_per_channel_) - 1; |
+ // 2 << 11 = 2048 would be 1.0 with our exponent. |
+ return 2048.0 / max_input_value; |
+} |
+ |
+float HalfFloatMaker_xor::Offset() const { |
+ return 0.5; |
+} |
+ |
+void HalfFloatMaker_xor::MakeHalfFloats(const uint16_t* src, |
+ size_t num, |
+ uint16_t* dst) { |
+ // Micro-benchmarking indicates that the compiler does |
+ // a good enough job of optimizing this loop that trying |
+ // to manually operate on one uint64 at a time is not |
+ // actually helpful. |
+ // Note to future optimizers: Benchmark your optimizations! |
+ for (size_t i = 0; i < num; i++) |
+ dst[i] = src[i] | 0x3800; |
+} |
+ |
+} // namespace media |