mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
optimizing av_log2
Originally committed as revision 1515 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
425ed6e223
commit
c81f034988
@ -27,6 +27,17 @@ const UINT8 ff_sqrt_tab[128]={
|
|||||||
9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11
|
9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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
|
||||||
|
};
|
||||||
|
|
||||||
void init_put_bits(PutBitContext *s,
|
void init_put_bits(PutBitContext *s,
|
||||||
UINT8 *buffer, int buffer_size,
|
UINT8 *buffer, int buffer_size,
|
||||||
void *opaque,
|
void *opaque,
|
||||||
|
@ -804,6 +804,7 @@ void print_stats(void);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* misc math functions */
|
/* misc math functions */
|
||||||
|
extern const uint8_t ff_log2_tab[256];
|
||||||
|
|
||||||
static inline int av_log2(unsigned int v)
|
static inline int av_log2(unsigned int v)
|
||||||
{
|
{
|
||||||
@ -818,20 +819,26 @@ static inline int av_log2(unsigned int v)
|
|||||||
v >>= 8;
|
v >>= 8;
|
||||||
n += 8;
|
n += 8;
|
||||||
}
|
}
|
||||||
if (v & 0xf0) {
|
n += ff_log2_tab[v];
|
||||||
v >>= 4;
|
|
||||||
n += 4;
|
|
||||||
}
|
|
||||||
if (v & 0xc) {
|
|
||||||
v >>= 2;
|
|
||||||
n += 2;
|
|
||||||
}
|
|
||||||
if (v & 0x2) {
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int av_log2_16bit(unsigned int v)
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
if (v & 0xff00) {
|
||||||
|
v >>= 8;
|
||||||
|
n += 8;
|
||||||
|
}
|
||||||
|
n += ff_log2_tab[v];
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* median of 3 */
|
/* median of 3 */
|
||||||
static inline int mid_pred(int a, int b, int c)
|
static inline int mid_pred(int a, int b, int c)
|
||||||
{
|
{
|
||||||
@ -861,7 +868,7 @@ static inline int clip(int a, int amin, int amax)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* math */
|
/* math */
|
||||||
extern const UINT8 ff_sqrt_tab[128];
|
extern const uint8_t ff_sqrt_tab[128];
|
||||||
|
|
||||||
int ff_gcd(int a, int b);
|
int ff_gcd(int a, int b);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user