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
1313
1414 API changes, most recent first:
1515
16+2012-xx-xx - xxxxxxx - lavu 52.1.0 - intmath.h
17+ Add av_ctz() for trailing zero bit count
18+
1619 2012-10-18 - xxxxxxx - lavu 51.45.0 - error.h
1720 Add AVERROR_EXPERIMENTAL
1821
libavutil/Makefile+1−1
@@ -67,10 +67,10 @@ OBJS = adler32.o \ · 66 unmodified lines
6767 float_dsp.o \
6868 imgutils.o \
6969 intfloat_readwrite.o \
70+ intmath.o \
7071 lfg.o \
7172 lls.o \
7273 log.o \
73− log2.o \
7474 log2_tab.o \
7575 mathematics.o \
7676 md5.o \
libavutil/intmath.crenamed from libavutil/log2.c+5−0
@@ -32,3 +32,8 @@ int av_log2_16bit(unsigned v) · 31 unmodified lines
3232 {
3333 return ff_log2_16bit(v);
3434 }
35+
36+int 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
8585 #define av_log2 ff_log2
8686 #define av_log2_16bit ff_log2_16bit
8787
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
105+static 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+ */
141+int av_ctz(int v);
142+
88143 /**
89144 * @}
90145 */
libavutil/version.h+1−1
@@ -37,7 +37,7 @@ · 36 unmodified lines
3737 */
3838
3939 #define LIBAVUTIL_VERSION_MAJOR 52
40−#define LIBAVUTIL_VERSION_MINOR 0
40+#define LIBAVUTIL_VERSION_MINOR 1
4141 #define LIBAVUTIL_VERSION_MICRO 0
4242
4343 #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