Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
c9084cd0
Commit
c9084cd0
authored
Dec 27, 2022
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/palettegen: use lowbias32 for color hashing
1.12x faster overall in palettegen on my machine.
parent
3cafbdc0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
17 deletions
+2
-17
vf_palettegen.c
libavfilter/vf_palettegen.c
+2
-17
No files found.
libavfilter/vf_palettegen.c
View file @
c9084cd0
...
...
@@ -63,8 +63,7 @@ enum {
NB_STATS_MODE
};
#define NBITS 5
#define HIST_SIZE (1<<(3*NBITS))
#define HIST_SIZE (1<<15)
typedef
struct
PaletteGenContext
{
const
AVClass
*
class
;
...
...
@@ -387,27 +386,13 @@ static AVFrame *get_palette_frame(AVFilterContext *ctx)
return
out
;
}
/**
* Hashing function for the color.
* It keeps the NBITS least significant bit of each component to make it
* "random" even if the scene doesn't have much different colors.
*/
static
inline
unsigned
color_hash
(
uint32_t
color
)
{
const
uint8_t
r
=
color
>>
16
&
((
1
<<
NBITS
)
-
1
);
const
uint8_t
g
=
color
>>
8
&
((
1
<<
NBITS
)
-
1
);
const
uint8_t
b
=
color
&
((
1
<<
NBITS
)
-
1
);
return
r
<<
(
NBITS
*
2
)
|
g
<<
NBITS
|
b
;
}
/**
* Locate the color in the hash table and increment its counter.
*/
static
int
color_inc
(
struct
hist_node
*
hist
,
uint32_t
color
)
{
int
i
;
const
u
nsigned
hash
=
color_hash
(
color
);
const
u
int32_t
hash
=
ff_lowbias32
(
color
)
&
(
HIST_SIZE
-
1
);
struct
hist_node
*
node
=
&
hist
[
hash
];
struct
color_ref
*
e
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment