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

Side by Side Diff: base/bits.h

Issue 11413005: YUV software decode path stride fixes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cc LGTM'ed. Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | cc/texture_uploader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file defines some bit utilities. 5 // This file defines some bit utilities.
6 6
7 #ifndef BASE_BITS_H_ 7 #ifndef BASE_BITS_H_
8 #define BASE_BITS_H_ 8 #define BASE_BITS_H_
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 23 matching lines...) Expand all
34 // Returns the integer i such as 2^(i-1) < n <= 2^i 34 // Returns the integer i such as 2^(i-1) < n <= 2^i
35 inline int Log2Ceiling(uint32 n) { 35 inline int Log2Ceiling(uint32 n) {
36 if (n == 0) { 36 if (n == 0) {
37 return -1; 37 return -1;
38 } else { 38 } else {
39 // Log2Floor returns -1 for 0, so the following works correctly for n=1. 39 // Log2Floor returns -1 for 0, so the following works correctly for n=1.
40 return 1 + Log2Floor(n - 1); 40 return 1 + Log2Floor(n - 1);
41 } 41 }
42 } 42 }
43 43
44 // Returns the largest i such as i <= n and i == k * mul for some integer k
45 inline uint32 RoundDown(uint32 n, uint32 mul) {
46 return (n / mul) * mul;
47 }
48
49 // Returns the smallest i such as i >= n and i == k * mul for some integer k
50 inline uint32 RoundUp(uint32 n, uint32 mul) {
51 return (n + (mul - 1)) / mul * mul;
jar (doing other things) 2012/11/20 22:54:35 Does this do what you want when: n + mul - 1 > UIN
sheu 2012/11/20 23:13:50 It doesn't but I don't really have other suggestio
52 }
53
44 } // namespace bits 54 } // namespace bits
45 } // namespace base 55 } // namespace base
46 56
47 #endif // BASE_BITS_H_ 57 #endif // BASE_BITS_H_
OLDNEW
« no previous file with comments | « no previous file | cc/texture_uploader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698