History

lavu: add av_ctz() for trailing zero bit count

Justin Ruggles committed 14 years ago

Commit dfde8a31 parent 6a744d25 files · +65 −2Browse files

Unified · Split

5 files
  1. doc/APIchanges +3 −0
  2. libavutil/Makefile +1 −1
  3. libavutil/intmath.c +5 −0
  4. libavutil/intmath.h +55 −0
  5. libavutil/version.h +1 −1
doc/APIchanges+3−0
@@ -13,6 +13,9 @@ libavutil: 2012-10-22 · 12 unmodified lines
13 13
14API changes, most recent first:14API changes, most recent first:
15 15
162012-xx-xx - xxxxxxx - lavu 52.1.0 - intmath.h
17 Add av_ctz() for trailing zero bit count
18
162012-10-18 - xxxxxxx - lavu 51.45.0 - error.h192012-10-18 - xxxxxxx - lavu 51.45.0 - error.h
17 Add AVERROR_EXPERIMENTAL20 Add AVERROR_EXPERIMENTAL
18 21
libavutil/Makefile+1−1
@@ -67,10 +67,10 @@ OBJS = adler32.o \ · 66 unmodified lines
67 float_dsp.o \67 float_dsp.o \
68 imgutils.o \68 imgutils.o \
69 intfloat_readwrite.o \69 intfloat_readwrite.o \
70 intmath.o \
70 lfg.o \71 lfg.o \
71 lls.o \72 lls.o \
72 log.o \73 log.o \
73 log2.o \
74 log2_tab.o \74 log2_tab.o \
75 mathematics.o \75 mathematics.o \
76 md5.o \76 md5.o \
libavutil/intmath.crenamed from libavutil/log2.c+5−0
@@ -32,3 +32,8 @@ int av_log2_16bit(unsigned v) · 31 unmodified lines
32{32{
33 return ff_log2_16bit(v);33 return ff_log2_16bit(v);
34}34}
35
36int av_ctz(int v)
37{
38 return ff_ctz(v);
39}
libavutil/intmath.h+55−0
@@ -85,6 +85,61 @@ static av_always_inline av_const int ff_log2_16bit_c(unsigned int v) · 84 unmodified lines
85#define av_log2 ff_log285#define av_log2 ff_log2
86#define av_log2_16bit ff_log2_16bit86#define av_log2_16bit ff_log2_16bit
87 87
88/**
89 * @}
90 */
91
92/**
93 * @addtogroup lavu_math
94 * @{
95 */
96
97#if HAVE_FAST_CLZ && AV_GCC_VERSION_AT_LEAST(3,4)
98#ifndef ff_ctz
99#define ff_ctz(v) __builtin_ctz(v)
100#endif
101#endif
102
103#ifndef ff_ctz
104#define ff_ctz ff_ctz_c
105static av_always_inline av_const int ff_ctz_c(int v)
106{
107 int c;
108
109 if (v & 0x1)
110 return 0;
111
112 c = 1;
113 if (!(v & 0xffff)) {
114 v >>= 16;
115 c += 16;
116 }
117 if (!(v & 0xff)) {
118 v >>= 8;
119 c += 8;
120 }
121 if (!(v & 0xf)) {
122 v >>= 4;
123 c += 4;
124 }
125 if (!(v & 0x3)) {
126 v >>= 2;
127 c += 2;
128 }
129 c -= v & 0x1;
130
131 return c;
132}
133#endif
134
135/**
136 * Trailing zero bit count.
137 *
138 * @param v input value. If v is 0, the result is undefined.
139 * @return the number of trailing 0-bits
140 */
141int av_ctz(int v);
142
88/**143/**
89 * @}144 * @}
90 */145 */
libavutil/version.h+1−1
@@ -37,7 +37,7 @@ · 36 unmodified lines
37 */37 */
38 38
39#define LIBAVUTIL_VERSION_MAJOR 5239#define LIBAVUTIL_VERSION_MAJOR 52
40#define LIBAVUTIL_VERSION_MINOR 040#define LIBAVUTIL_VERSION_MINOR 1
41#define LIBAVUTIL_VERSION_MICRO 041#define LIBAVUTIL_VERSION_MICRO 0
42 42
43#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \43#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t