mirror of https://git.ffmpeg.org/ffmpeg.git
avfilter/paletteuse: use lowbias32 for color hashing
Impact is more negligible than previous commit but still faster (1.02x).
This commit is contained in:
parent
c9084cd0e2
commit
6c7b54e962
|
@ -70,8 +70,7 @@ struct color_node {
|
||||||
int left_id, right_id;
|
int left_id, right_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NBITS 5
|
#define CACHE_SIZE (1<<15)
|
||||||
#define CACHE_SIZE (1<<(3*NBITS))
|
|
||||||
|
|
||||||
struct cached_color {
|
struct cached_color {
|
||||||
uint32_t color;
|
uint32_t color;
|
||||||
|
@ -347,10 +346,7 @@ static av_always_inline int color_get(PaletteUseContext *s, uint32_t color,
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct color_info clrinfo;
|
struct color_info clrinfo;
|
||||||
const uint8_t rhash = (color>>16) & ((1<<NBITS)-1);
|
const uint32_t hash = ff_lowbias32(color) & (CACHE_SIZE - 1);
|
||||||
const uint8_t ghash = (color>> 8) & ((1<<NBITS)-1);
|
|
||||||
const uint8_t bhash = color & ((1<<NBITS)-1);
|
|
||||||
const unsigned hash = rhash<<(NBITS*2) | ghash<<NBITS | bhash;
|
|
||||||
struct cache_node *node = &s->cache[hash];
|
struct cache_node *node = &s->cache[hash];
|
||||||
struct cached_color *e;
|
struct cached_color *e;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue