summaryrefslogtreecommitdiff
path: root/apps/codecs/lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/lib')
-rw-r--r--apps/codecs/lib/codeclib.c12
-rw-r--r--apps/codecs/lib/codeclib.h36
2 files changed, 48 insertions, 0 deletions
diff --git a/apps/codecs/lib/codeclib.c b/apps/codecs/lib/codeclib.c
index 8cc40894e3..1c624e0f8c 100644
--- a/apps/codecs/lib/codeclib.c
+++ b/apps/codecs/lib/codeclib.c
@@ -138,6 +138,18 @@ void qsort(void *base, size_t nmemb, size_t size,
138 ci->qsort(base,nmemb,size,compar); 138 ci->qsort(base,nmemb,size,compar);
139} 139}
140 140
141/* From ffmpeg - libavutil/common.h */
142const uint8_t ff_log2_tab[256] ICONST_ATTR = {
143 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
144 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
145 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
146 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
147 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
148 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
149 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
150 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
151};
152
141#ifdef RB_PROFILE 153#ifdef RB_PROFILE
142void __cyg_profile_func_enter(void *this_fn, void *call_site) { 154void __cyg_profile_func_enter(void *this_fn, void *call_site) {
143#ifdef CPU_COLDFIRE 155#ifdef CPU_COLDFIRE
diff --git a/apps/codecs/lib/codeclib.h b/apps/codecs/lib/codeclib.h
index e7f45d3572..bf7b41775a 100644
--- a/apps/codecs/lib/codeclib.h
+++ b/apps/codecs/lib/codeclib.h
@@ -19,6 +19,9 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22#ifndef __CODECLIB_H__
23#define __CODECLIB_H__
24
22#include "config.h" 25#include "config.h"
23#include "codecs.h" 26#include "codecs.h"
24#include <sys/types.h> 27#include <sys/types.h>
@@ -71,6 +74,37 @@ unsigned udiv32_arm(unsigned a, unsigned b);
71#define UDIV32(a, b) (a / b) 74#define UDIV32(a, b) (a / b)
72#endif 75#endif
73 76
77/* TODO figure out if we really need to care about calculating
78 av_log2(0) */
79#if (defined(CPU_ARM) && (ARM_ARCH > 4))
80static inline unsigned int av_log2(uint32_t v)
81{
82 unsigned int lz = __builtin_clz(v);
83 return 31 - lz + (lz >> 5); /* make sure av_log2(0) returns 0 */
84}
85#else
86/* From libavutil/common.h */
87extern const uint8_t ff_log2_tab[256] ICONST_ATTR;
88
89static inline unsigned int av_log2(unsigned int v)
90{
91 int n;
92
93 n = 0;
94 if (v & 0xffff0000) {
95 v >>= 16;
96 n += 16;
97 }
98 if (v & 0xff00) {
99 v >>= 8;
100 n += 8;
101 }
102 n += ff_log2_tab[v];
103
104 return n;
105}
106#endif
107
74/* Various codec helper functions */ 108/* Various codec helper functions */
75 109
76int codec_init(void); 110int codec_init(void);
@@ -82,3 +116,5 @@ void __cyg_profile_func_enter(void *this_fn, void *call_site)
82void __cyg_profile_func_exit(void *this_fn, void *call_site) 116void __cyg_profile_func_exit(void *this_fn, void *call_site)
83 NO_PROF_ATTR ICODE_ATTR; 117 NO_PROF_ATTR ICODE_ATTR;
84#endif 118#endif
119
120#endif /* __CODECLIB_H__ */