diff options
| author | Mohamed Tarek <mt@rockbox.org> | 2009-05-12 20:50:35 +0000 |
|---|---|---|
| committer | Mohamed Tarek <mt@rockbox.org> | 2009-05-12 20:50:35 +0000 |
| commit | 49ba646d579a89d5ff0e4f3d5eea237eea22aafd (patch) | |
| tree | 32aa872eb82b16c22f1915543c1512b116513209 /apps/codecs/libcook/cook_fixpoint.h | |
| parent | 49fccaf2d925def5cc57fff4a09b98a8fe318cc8 (diff) | |
| download | rockbox-49ba646d579a89d5ff0e4f3d5eea237eea22aafd.zip rockbox-49ba646d579a89d5ff0e4f3d5eea237eea22aafd.tar.gz rockbox-49ba646d579a89d5ff0e4f3d5eea237eea22aafd.tar.bz2 rockbox-49ba646d579a89d5ff0e4f3d5eea237eea22aafd.tar.xz | |
-Remove all dynamic allocations, hence remove cook_decode_close() which was basically
needed for freeing allocated memory.
-Remove any ffmpeg-specific attributes (av_const,av_always_inline .. etc.).
-Move some math functions to cook_fixpoint.h - libavutil/common.h is no longer
needed.
-Remove libavutil/mem.[c/h], libavutil/common.h and libavutil/internal.h.
-Fix a warning in cookdata_fixpoint.h.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20922 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libcook/cook_fixpoint.h')
| -rw-r--r-- | apps/codecs/libcook/cook_fixpoint.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/apps/codecs/libcook/cook_fixpoint.h b/apps/codecs/libcook/cook_fixpoint.h index 83c054c..0f12b13 100644 --- a/apps/codecs/libcook/cook_fixpoint.h +++ b/apps/codecs/libcook/cook_fixpoint.h @@ -35,6 +35,24 @@ * in C using two 32 bit integer multiplications. */ +/* The following table is taken from libavutil/mathematics.c */ +const uint8_t ff_log2_tab[256]={ + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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 +}; + +/* cplscales was moved from cookdata_fixpoint.h since only * + * cook_fixpoint.h should see/use it. */ +static const FIXPU* cplscales[5] = { + cplscale2, cplscale3, cplscale4, cplscale5, cplscale6 +}; + /** * Initialise fixed point implementation. * Nothing to do for fixed point. @@ -86,6 +104,37 @@ static inline FIXP fixp_mult_su(FIXP a, FIXPU b) return hb + (lb >> 16) + ((lb & 0x8000) >> 15); } +/* math functions taken from libavutil/common.h */ + +static inline int av_log2(unsigned int v) +{ + int n = 0; + if (v & 0xffff0000) { + v >>= 16; + n += 16; + } + if (v & 0xff00) { + v >>= 8; + n += 8; + } + n += ff_log2_tab[v]; + + return n; +} + +/** + * Clips a signed integer value into the amin-amax range. + * @param a value to clip + * @param amin minimum value of the clip range + * @param amax maximum value of the clip range + * @return clipped value + */ +static inline int av_clip(int a, int amin, int amax) +{ + if (a < amin) return amin; + else if (a > amax) return amax; + else return a; +} /** * The real requantization of the mltcoefs |