Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
afaaf8db
Commit
afaaf8db
authored
Dec 27, 2016
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi/selectivecolor: simplify crazy mid val computations
parent
571a3601
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
30 deletions
+3
-30
vf_selectivecolor.c
libavfilter/vf_selectivecolor.c
+3
-30
No files found.
libavfilter/vf_selectivecolor.c
View file @
afaaf8db
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/pixdesc.h"
#include "libavcodec/mathops.h" // for mid_pred(), which is a macro so no link dependency
#include "avfilter.h"
#include "avfilter.h"
#include "drawutils.h"
#include "drawutils.h"
#include "formats.h"
#include "formats.h"
...
@@ -112,42 +113,14 @@ static const AVOption selectivecolor_options[] = {
...
@@ -112,42 +113,14 @@ static const AVOption selectivecolor_options[] = {
AVFILTER_DEFINE_CLASS
(
selectivecolor
);
AVFILTER_DEFINE_CLASS
(
selectivecolor
);
static
inline
int
get_mid_val
(
int
r
,
int
g
,
int
b
)
{
if
((
r
<
g
&&
r
>
b
)
||
(
r
<
b
&&
r
>
g
))
return
r
;
if
((
g
<
r
&&
g
>
b
)
||
(
g
<
b
&&
g
>
r
))
return
g
;
if
((
b
<
r
&&
b
>
g
)
||
(
b
<
g
&&
b
>
r
))
return
b
;
return
-
1
;
}
static
int
get_rgb_adjust_range
(
int
r
,
int
g
,
int
b
,
int
min_val
,
int
max_val
)
static
int
get_rgb_adjust_range
(
int
r
,
int
g
,
int
b
,
int
min_val
,
int
max_val
)
{
{
// max - mid
return
max_val
-
mid_pred
(
r
,
g
,
b
);
const
int
mid_val
=
get_mid_val
(
r
,
g
,
b
);
if
(
mid_val
==
-
1
)
{
// XXX: can be simplified
if
((
r
!=
min_val
&&
g
==
min_val
&&
b
==
min_val
)
||
(
r
==
min_val
&&
g
!=
min_val
&&
b
==
min_val
)
||
(
r
==
min_val
&&
g
==
min_val
&&
b
!=
min_val
))
return
max_val
-
min_val
;
return
0
;
}
return
max_val
-
mid_val
;
}
}
static
int
get_cmy_adjust_range
(
int
r
,
int
g
,
int
b
,
int
min_val
,
int
max_val
)
static
int
get_cmy_adjust_range
(
int
r
,
int
g
,
int
b
,
int
min_val
,
int
max_val
)
{
{
// mid - min
return
mid_pred
(
r
,
g
,
b
)
-
min_val
;
const
int
mid_val
=
get_mid_val
(
r
,
g
,
b
);
if
(
mid_val
==
-
1
)
{
// XXX: refactor with rgb
if
((
r
!=
max_val
&&
g
==
max_val
&&
b
==
max_val
)
||
(
r
==
max_val
&&
g
!=
max_val
&&
b
==
max_val
)
||
(
r
==
max_val
&&
g
==
max_val
&&
b
!=
max_val
))
return
max_val
-
min_val
;
return
0
;
}
return
mid_val
-
min_val
;
}
}
#define DECLARE_ADJUST_RANGE_FUNCS(nbits) \
#define DECLARE_ADJUST_RANGE_FUNCS(nbits) \
...
...
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