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

Side by Side Diff: media/video/half_float_maker_lib_yuv.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 unified diff | Download patch
OLDNEW
(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_lib_yuv.h"
6 #include "third_party/libyuv/include/libyuv.h"
7
8 namespace media {
9
10 HalfFloatMaker_libyuv::HalfFloatMaker_libyuv(int bits_per_channel) {
11 int max_value = (1 << bits_per_channel) - 1;
12 // For less than 15 bits, we can give libyuv a multiplier of
13 // 1.0, which is faster on some platforms. If bits is 16 or larger,
14 // a multiplier of 1.0 would cause overflows. However, a multiplier
15 // of 1/max_value would cause subnormal floats, which perform
16 // very poorly on some platforms.
17 if (bits_per_channel <= 15) {
18 libyuv_multiplier_ = 1.0f;
19 } else {
20 // This multiplier makes sure that we avoid subnormal values.
21 libyuv_multiplier_ = 1.0f / 4096.0f;
22 }
23 resource_multiplier_ = 1.0f / libyuv_multiplier_ / max_value;
24 }
25
26 float HalfFloatMaker_libyuv::Offset() const {
27 return 0.5;
28 }
29
30 float HalfFloatMaker_libyuv::Multiplier() const {
31 return resource_multiplier_;
32 }
33
34 void HalfFloatMaker_libyuv::MakeHalfFloats(const uint16_t* src,
35 size_t num,
36 uint16_t* dst) {
37 // Source and dest stride can be zero since we're only copying
38 // one row at a time.
39 int stride = 0;
40 int rows = 1;
41 libyuv::HalfFloatPlane(src, stride, dst, stride, libyuv_multiplier_, num,
42 rows);
43 }
44
45 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698