Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Unified Diff: media/video/half_float_maker_xor.cc

Issue 2763503002: Move HalfFloatMaker to media (Closed)
Patch Set: Moved HalffloatMaker and its implementation from cc to media Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« media/video/half_float_maker_xor.h ('K') | « media/video/half_float_maker_xor.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« media/video/half_float_maker_xor.h ('K') | « media/video/half_float_maker_xor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698