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
931e2c45
Commit
931e2c45
authored
May 05, 2018
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_colorchannelmixer: refactor code
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
2017b4b1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
151 deletions
+49
-151
vf_colorchannelmixer.c
libavfilter/vf_colorchannelmixer.c
+49
-151
No files found.
libavfilter/vf_colorchannelmixer.c
View file @
931e2c45
...
...
@@ -93,7 +93,8 @@ static int query_formats(AVFilterContext *ctx)
return
ff_set_common_formats
(
ctx
,
fmts_list
);
}
static
int
filter_slice_rgba64
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
static
av_always_inline
int
filter_slice_rgba_packed
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
,
int
have_alpha
,
int
step
)
{
ColorChannelMixerContext
*
s
=
ctx
->
priv
;
ThreadData
*
td
=
arg
;
...
...
@@ -110,31 +111,31 @@ static int filter_slice_rgba64(AVFilterContext *ctx, void *arg, int jobnr, int n
int
i
,
j
;
for
(
i
=
slice_start
;
i
<
slice_end
;
i
++
)
{
const
uint
16_t
*
src
=
(
const
uint16_t
*
)
srcrow
;
uint
16_t
*
dst
=
(
uint16_t
*
)
dstrow
;
const
uint
8_t
*
src
=
srcrow
;
uint
8_t
*
dst
=
dstrow
;
for
(
j
=
0
;
j
<
out
->
width
*
4
;
j
+=
4
)
{
const
uint
16
_t
rin
=
src
[
j
+
roffset
];
const
uint
16
_t
gin
=
src
[
j
+
goffset
];
const
uint
16
_t
bin
=
src
[
j
+
boffset
];
const
uint
16
_t
ain
=
src
[
j
+
aoffset
];
for
(
j
=
0
;
j
<
out
->
width
*
step
;
j
+=
step
)
{
const
uint
8
_t
rin
=
src
[
j
+
roffset
];
const
uint
8
_t
gin
=
src
[
j
+
goffset
];
const
uint
8
_t
bin
=
src
[
j
+
boffset
];
const
uint
8
_t
ain
=
src
[
j
+
aoffset
];
dst
[
j
+
roffset
]
=
av_clip_uint
16
(
s
->
lut
[
R
][
R
][
rin
]
+
dst
[
j
+
roffset
]
=
av_clip_uint
8
(
s
->
lut
[
R
][
R
][
rin
]
+
s
->
lut
[
R
][
G
][
gin
]
+
s
->
lut
[
R
][
B
][
bin
]
+
s
->
lut
[
R
][
A
][
ain
]);
dst
[
j
+
goffset
]
=
av_clip_uint16
(
s
->
lut
[
G
][
R
][
rin
]
+
s
->
lut
[
R
][
B
][
bin
]);
dst
[
j
+
goffset
]
=
av_clip_uint8
(
s
->
lut
[
G
][
R
][
rin
]
+
s
->
lut
[
G
][
G
][
gin
]
+
s
->
lut
[
G
][
B
][
bin
]
+
s
->
lut
[
G
][
A
][
ain
]);
dst
[
j
+
boffset
]
=
av_clip_uint16
(
s
->
lut
[
B
][
R
][
rin
]
+
s
->
lut
[
G
][
B
][
bin
]);
dst
[
j
+
boffset
]
=
av_clip_uint8
(
s
->
lut
[
B
][
R
][
rin
]
+
s
->
lut
[
B
][
G
][
gin
]
+
s
->
lut
[
B
][
B
][
bin
]
+
s
->
lut
[
B
][
A
][
ain
]);
dst
[
j
+
aoffset
]
=
av_clip_uint16
(
s
->
lut
[
A
][
R
][
rin
]
+
s
->
lut
[
B
][
B
][
bin
]);
if
(
have_alpha
==
1
)
{
dst
[
j
+
aoffset
]
=
av_clip_uint8
(
s
->
lut
[
A
][
R
][
rin
]
+
s
->
lut
[
A
][
G
][
gin
]
+
s
->
lut
[
A
][
B
][
bin
]
+
s
->
lut
[
A
][
A
][
ain
]);
}
else
if
(
have_alpha
==
-
1
&&
in
!=
out
)
dst
[
j
+
aoffset
]
=
0
;
}
srcrow
+=
in
->
linesize
[
0
];
...
...
@@ -144,7 +145,8 @@ static int filter_slice_rgba64(AVFilterContext *ctx, void *arg, int jobnr, int n
return
0
;
}
static
int
filter_slice_rgb48
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
static
av_always_inline
int
filter_slice_rgba16_packed
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
,
int
have_alpha
,
int
step
)
{
ColorChannelMixerContext
*
s
=
ctx
->
priv
;
ThreadData
*
td
=
arg
;
...
...
@@ -155,6 +157,7 @@ static int filter_slice_rgb48(AVFilterContext *ctx, void *arg, int jobnr, int nb
const
uint8_t
roffset
=
s
->
rgba_map
[
R
];
const
uint8_t
goffset
=
s
->
rgba_map
[
G
];
const
uint8_t
boffset
=
s
->
rgba_map
[
B
];
const
uint8_t
aoffset
=
s
->
rgba_map
[
A
];
const
uint8_t
*
srcrow
=
in
->
data
[
0
]
+
slice_start
*
in
->
linesize
[
0
];
uint8_t
*
dstrow
=
out
->
data
[
0
]
+
slice_start
*
out
->
linesize
[
0
];
int
i
,
j
;
...
...
@@ -163,10 +166,11 @@ static int filter_slice_rgb48(AVFilterContext *ctx, void *arg, int jobnr, int nb
const
uint16_t
*
src
=
(
const
uint16_t
*
)
srcrow
;
uint16_t
*
dst
=
(
uint16_t
*
)
dstrow
;
for
(
j
=
0
;
j
<
out
->
width
*
3
;
j
+=
3
)
{
for
(
j
=
0
;
j
<
out
->
width
*
step
;
j
+=
step
)
{
const
uint16_t
rin
=
src
[
j
+
roffset
];
const
uint16_t
gin
=
src
[
j
+
goffset
];
const
uint16_t
bin
=
src
[
j
+
boffset
];
const
uint16_t
ain
=
src
[
j
+
aoffset
];
dst
[
j
+
roffset
]
=
av_clip_uint16
(
s
->
lut
[
R
][
R
][
rin
]
+
s
->
lut
[
R
][
G
][
gin
]
+
...
...
@@ -177,57 +181,13 @@ static int filter_slice_rgb48(AVFilterContext *ctx, void *arg, int jobnr, int nb
dst
[
j
+
boffset
]
=
av_clip_uint16
(
s
->
lut
[
B
][
R
][
rin
]
+
s
->
lut
[
B
][
G
][
gin
]
+
s
->
lut
[
B
][
B
][
bin
]);
}
srcrow
+=
in
->
linesize
[
0
];
dstrow
+=
out
->
linesize
[
0
];
}
return
0
;
}
static
int
filter_slice_rgba
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
{
ColorChannelMixerContext
*
s
=
ctx
->
priv
;
ThreadData
*
td
=
arg
;
AVFrame
*
in
=
td
->
in
;
AVFrame
*
out
=
td
->
out
;
const
int
slice_start
=
(
out
->
height
*
jobnr
)
/
nb_jobs
;
const
int
slice_end
=
(
out
->
height
*
(
jobnr
+
1
))
/
nb_jobs
;
const
uint8_t
roffset
=
s
->
rgba_map
[
R
];
const
uint8_t
goffset
=
s
->
rgba_map
[
G
];
const
uint8_t
boffset
=
s
->
rgba_map
[
B
];
const
uint8_t
aoffset
=
s
->
rgba_map
[
A
];
const
uint8_t
*
srcrow
=
in
->
data
[
0
]
+
slice_start
*
in
->
linesize
[
0
];
uint8_t
*
dstrow
=
out
->
data
[
0
]
+
slice_start
*
out
->
linesize
[
0
];
int
i
,
j
;
for
(
i
=
slice_start
;
i
<
slice_end
;
i
++
)
{
const
uint8_t
*
src
=
srcrow
;
uint8_t
*
dst
=
dstrow
;
for
(
j
=
0
;
j
<
out
->
width
*
4
;
j
+=
4
)
{
const
uint8_t
rin
=
src
[
j
+
roffset
];
const
uint8_t
gin
=
src
[
j
+
goffset
];
const
uint8_t
bin
=
src
[
j
+
boffset
];
const
uint8_t
ain
=
src
[
j
+
aoffset
];
dst
[
j
+
roffset
]
=
av_clip_uint8
(
s
->
lut
[
R
][
R
][
rin
]
+
s
->
lut
[
R
][
G
][
gin
]
+
s
->
lut
[
R
][
B
][
bin
]
+
s
->
lut
[
R
][
A
][
ain
]);
dst
[
j
+
goffset
]
=
av_clip_uint8
(
s
->
lut
[
G
][
R
][
rin
]
+
s
->
lut
[
G
][
G
][
gin
]
+
s
->
lut
[
G
][
B
][
bin
]
+
s
->
lut
[
G
][
A
][
ain
]);
dst
[
j
+
boffset
]
=
av_clip_uint8
(
s
->
lut
[
B
][
R
][
rin
]
+
s
->
lut
[
B
][
G
][
gin
]
+
s
->
lut
[
B
][
B
][
bin
]
+
s
->
lut
[
B
][
A
][
ain
]);
dst
[
j
+
aoffset
]
=
av_clip_uint8
(
s
->
lut
[
A
][
R
][
rin
]
+
if
(
have_alpha
==
1
)
{
dst
[
j
+
aoffset
]
=
av_clip_uint16
(
s
->
lut
[
A
][
R
][
rin
]
+
s
->
lut
[
A
][
G
][
gin
]
+
s
->
lut
[
A
][
B
][
bin
]
+
s
->
lut
[
A
][
A
][
ain
]);
}
else
if
(
have_alpha
==
-
1
&&
in
!=
out
)
dst
[
j
+
aoffset
]
=
0
;
}
srcrow
+=
in
->
linesize
[
0
];
...
...
@@ -237,91 +197,29 @@ static int filter_slice_rgba(AVFilterContext *ctx, void *arg, int jobnr, int nb_
return
0
;
}
static
int
filter_slice_rgb
2
4
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
static
int
filter_slice_rgb
a6
4
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
{
ColorChannelMixerContext
*
s
=
ctx
->
priv
;
ThreadData
*
td
=
arg
;
AVFrame
*
in
=
td
->
in
;
AVFrame
*
out
=
td
->
out
;
const
int
slice_start
=
(
out
->
height
*
jobnr
)
/
nb_jobs
;
const
int
slice_end
=
(
out
->
height
*
(
jobnr
+
1
))
/
nb_jobs
;
const
uint8_t
roffset
=
s
->
rgba_map
[
R
];
const
uint8_t
goffset
=
s
->
rgba_map
[
G
];
const
uint8_t
boffset
=
s
->
rgba_map
[
B
];
const
uint8_t
*
srcrow
=
in
->
data
[
0
]
+
slice_start
*
in
->
linesize
[
0
];
uint8_t
*
dstrow
=
out
->
data
[
0
]
+
slice_start
*
out
->
linesize
[
0
];
int
i
,
j
;
for
(
i
=
slice_start
;
i
<
slice_end
;
i
++
)
{
const
uint8_t
*
src
=
srcrow
;
uint8_t
*
dst
=
dstrow
;
for
(
j
=
0
;
j
<
out
->
width
*
3
;
j
+=
3
)
{
const
uint8_t
rin
=
src
[
j
+
roffset
];
const
uint8_t
gin
=
src
[
j
+
goffset
];
const
uint8_t
bin
=
src
[
j
+
boffset
];
return
filter_slice_rgba16_packed
(
ctx
,
arg
,
jobnr
,
nb_jobs
,
1
,
4
);
}
dst
[
j
+
roffset
]
=
av_clip_uint8
(
s
->
lut
[
R
][
R
][
rin
]
+
s
->
lut
[
R
][
G
][
gin
]
+
s
->
lut
[
R
][
B
][
bin
]);
dst
[
j
+
goffset
]
=
av_clip_uint8
(
s
->
lut
[
G
][
R
][
rin
]
+
s
->
lut
[
G
][
G
][
gin
]
+
s
->
lut
[
G
][
B
][
bin
]);
dst
[
j
+
boffset
]
=
av_clip_uint8
(
s
->
lut
[
B
][
R
][
rin
]
+
s
->
lut
[
B
][
G
][
gin
]
+
s
->
lut
[
B
][
B
][
bin
]);
}
static
int
filter_slice_rgb48
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
{
return
filter_slice_rgba16_packed
(
ctx
,
arg
,
jobnr
,
nb_jobs
,
0
,
3
);
}
srcrow
+=
in
->
linesize
[
0
];
dstrow
+=
out
->
linesize
[
0
];
}
static
int
filter_slice_rgba
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
{
return
filter_slice_rgba_packed
(
ctx
,
arg
,
jobnr
,
nb_jobs
,
1
,
4
);
}
return
0
;
static
int
filter_slice_rgb24
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
{
return
filter_slice_rgba_packed
(
ctx
,
arg
,
jobnr
,
nb_jobs
,
0
,
3
);
}
static
int
filter_slice_rgb0
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
{
ColorChannelMixerContext
*
s
=
ctx
->
priv
;
ThreadData
*
td
=
arg
;
AVFrame
*
in
=
td
->
in
;
AVFrame
*
out
=
td
->
out
;
const
int
slice_start
=
(
out
->
height
*
jobnr
)
/
nb_jobs
;
const
int
slice_end
=
(
out
->
height
*
(
jobnr
+
1
))
/
nb_jobs
;
const
uint8_t
roffset
=
s
->
rgba_map
[
R
];
const
uint8_t
goffset
=
s
->
rgba_map
[
G
];
const
uint8_t
boffset
=
s
->
rgba_map
[
B
];
const
uint8_t
aoffset
=
s
->
rgba_map
[
A
];
const
uint8_t
*
srcrow
=
in
->
data
[
0
]
+
slice_start
*
in
->
linesize
[
0
];
uint8_t
*
dstrow
=
out
->
data
[
0
]
+
slice_start
*
out
->
linesize
[
0
];
int
i
,
j
;
for
(
i
=
slice_start
;
i
<
slice_end
;
i
++
)
{
const
uint8_t
*
src
=
srcrow
;
uint8_t
*
dst
=
dstrow
;
for
(
j
=
0
;
j
<
out
->
width
*
4
;
j
+=
4
)
{
const
uint8_t
rin
=
src
[
j
+
roffset
];
const
uint8_t
gin
=
src
[
j
+
goffset
];
const
uint8_t
bin
=
src
[
j
+
boffset
];
dst
[
j
+
roffset
]
=
av_clip_uint8
(
s
->
lut
[
R
][
R
][
rin
]
+
s
->
lut
[
R
][
G
][
gin
]
+
s
->
lut
[
R
][
B
][
bin
]);
dst
[
j
+
goffset
]
=
av_clip_uint8
(
s
->
lut
[
G
][
R
][
rin
]
+
s
->
lut
[
G
][
G
][
gin
]
+
s
->
lut
[
G
][
B
][
bin
]);
dst
[
j
+
boffset
]
=
av_clip_uint8
(
s
->
lut
[
B
][
R
][
rin
]
+
s
->
lut
[
B
][
G
][
gin
]
+
s
->
lut
[
B
][
B
][
bin
]);
if
(
in
!=
out
)
dst
[
j
+
aoffset
]
=
0
;
}
srcrow
+=
in
->
linesize
[
0
];
dstrow
+=
out
->
linesize
[
0
];
}
return
0
;
return
filter_slice_rgba_packed
(
ctx
,
arg
,
jobnr
,
nb_jobs
,
-
1
,
4
);
}
static
int
config_output
(
AVFilterLink
*
outlink
)
...
...
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