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
13aec744
Commit
13aec744
authored
Feb 13, 2014
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/lut3d: support slice threading.
parent
ccc48b31
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
8 deletions
+22
-8
vf_lut3d.c
libavfilter/vf_lut3d.c
+22
-8
No files found.
libavfilter/vf_lut3d.c
View file @
13aec744
...
@@ -62,7 +62,7 @@ typedef struct LUT3DContext {
...
@@ -62,7 +62,7 @@ typedef struct LUT3DContext {
char
*
file
;
char
*
file
;
uint8_t
rgba_map
[
4
];
uint8_t
rgba_map
[
4
];
int
step
;
int
step
;
void
(
*
interp
)(
const
struct
LUT3DContext
*
,
AVFrame
*
out
,
const
AVFrame
*
in
)
;
avfilter_action_func
*
interp
;
struct
rgbvec
lut
[
MAX_LEVEL
][
MAX_LEVEL
][
MAX_LEVEL
];
struct
rgbvec
lut
[
MAX_LEVEL
][
MAX_LEVEL
][
MAX_LEVEL
];
int
lutsize
;
int
lutsize
;
#if CONFIG_HALDCLUT_FILTER
#if CONFIG_HALDCLUT_FILTER
...
@@ -74,6 +74,10 @@ typedef struct LUT3DContext {
...
@@ -74,6 +74,10 @@ typedef struct LUT3DContext {
#endif
#endif
}
LUT3DContext
;
}
LUT3DContext
;
typedef
struct
ThreadData
{
AVFrame
*
in
,
*
out
;
}
ThreadData
;
#define OFFSET(x) offsetof(LUT3DContext, x)
#define OFFSET(x) offsetof(LUT3DContext, x)
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
#define COMMON_OPTIONS \
#define COMMON_OPTIONS \
...
@@ -195,19 +199,25 @@ static inline struct rgbvec interp_tetrahedral(const LUT3DContext *lut3d,
...
@@ -195,19 +199,25 @@ static inline struct rgbvec interp_tetrahedral(const LUT3DContext *lut3d,
}
}
#define DEFINE_INTERP_FUNC(name, nbits) \
#define DEFINE_INTERP_FUNC(name, nbits) \
static
void interp_##nbits##_##name(const LUT3DContext *lut3d, AVFrame *out, const AVFrame *in)
\
static
int interp_##nbits##_##name(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
\
{ \
{ \
int x, y; \
int x, y; \
const LUT3DContext *lut3d = ctx->priv; \
const ThreadData *td = arg; \
const AVFrame *in = td->in; \
const AVFrame *out = td->out; \
const int direct = out == in; \
const int direct = out == in; \
const int step = lut3d->step; \
const int step = lut3d->step; \
const uint8_t r = lut3d->rgba_map[R]; \
const uint8_t r = lut3d->rgba_map[R]; \
const uint8_t g = lut3d->rgba_map[G]; \
const uint8_t g = lut3d->rgba_map[G]; \
const uint8_t b = lut3d->rgba_map[B]; \
const uint8_t b = lut3d->rgba_map[B]; \
const uint8_t a = lut3d->rgba_map[A]; \
const uint8_t a = lut3d->rgba_map[A]; \
uint8_t *dstrow = out->data[0]; \
const int slice_start = (in->height * jobnr ) / nb_jobs; \
const uint8_t *srcrow = in ->data[0]; \
const int slice_end = (in->height * (jobnr+1)) / nb_jobs; \
uint8_t *dstrow = out->data[0] + slice_start * out->linesize[0]; \
const uint8_t *srcrow = in ->data[0] + slice_start * in ->linesize[0]; \
\
\
for (y =
0; y < in->height; y++) {
\
for (y =
slice_start; y < slice_end; y++) {
\
uint##nbits##_t *dst = (uint##nbits##_t *)dstrow; \
uint##nbits##_t *dst = (uint##nbits##_t *)dstrow; \
const uint##nbits##_t *src = (const uint##nbits##_t *)srcrow; \
const uint##nbits##_t *src = (const uint##nbits##_t *)srcrow; \
for (x = 0; x < in->width * step; x += step) { \
for (x = 0; x < in->width * step; x += step) { \
...
@@ -225,6 +235,7 @@ static void interp_##nbits##_##name(const LUT3DContext *lut3d, AVFrame *out, con
...
@@ -225,6 +235,7 @@ static void interp_##nbits##_##name(const LUT3DContext *lut3d, AVFrame *out, con
dstrow += out->linesize[0]; \
dstrow += out->linesize[0]; \
srcrow += in ->linesize[0]; \
srcrow += in ->linesize[0]; \
} \
} \
return 0; \
}
}
DEFINE_INTERP_FUNC
(
nearest
,
8
)
DEFINE_INTERP_FUNC
(
nearest
,
8
)
...
@@ -490,6 +501,7 @@ static AVFrame *apply_lut(AVFilterLink *inlink, AVFrame *in)
...
@@ -490,6 +501,7 @@ static AVFrame *apply_lut(AVFilterLink *inlink, AVFrame *in)
LUT3DContext
*
lut3d
=
ctx
->
priv
;
LUT3DContext
*
lut3d
=
ctx
->
priv
;
AVFilterLink
*
outlink
=
inlink
->
dst
->
outputs
[
0
];
AVFilterLink
*
outlink
=
inlink
->
dst
->
outputs
[
0
];
AVFrame
*
out
;
AVFrame
*
out
;
ThreadData
td
;
if
(
av_frame_is_writable
(
in
))
{
if
(
av_frame_is_writable
(
in
))
{
out
=
in
;
out
=
in
;
...
@@ -502,7 +514,9 @@ static AVFrame *apply_lut(AVFilterLink *inlink, AVFrame *in)
...
@@ -502,7 +514,9 @@ static AVFrame *apply_lut(AVFilterLink *inlink, AVFrame *in)
av_frame_copy_props
(
out
,
in
);
av_frame_copy_props
(
out
,
in
);
}
}
lut3d
->
interp
(
lut3d
,
out
,
in
);
td
.
in
=
in
;
td
.
out
=
out
;
ctx
->
internal
->
execute
(
ctx
,
lut3d
->
interp
,
&
td
,
NULL
,
FFMIN
(
outlink
->
h
,
ctx
->
graph
->
nb_threads
));
if
(
out
!=
in
)
if
(
out
!=
in
)
av_frame_free
(
&
in
);
av_frame_free
(
&
in
);
...
@@ -605,7 +619,7 @@ AVFilter ff_vf_lut3d = {
...
@@ -605,7 +619,7 @@ AVFilter ff_vf_lut3d = {
.
inputs
=
lut3d_inputs
,
.
inputs
=
lut3d_inputs
,
.
outputs
=
lut3d_outputs
,
.
outputs
=
lut3d_outputs
,
.
priv_class
=
&
lut3d_class
,
.
priv_class
=
&
lut3d_class
,
.
flags
=
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
,
.
flags
=
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
|
AVFILTER_FLAG_SLICE_THREADS
,
};
};
#endif
#endif
...
@@ -784,6 +798,6 @@ AVFilter ff_vf_haldclut = {
...
@@ -784,6 +798,6 @@ AVFilter ff_vf_haldclut = {
.
inputs
=
haldclut_inputs
,
.
inputs
=
haldclut_inputs
,
.
outputs
=
haldclut_outputs
,
.
outputs
=
haldclut_outputs
,
.
priv_class
=
&
haldclut_class
,
.
priv_class
=
&
haldclut_class
,
.
flags
=
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
,
.
flags
=
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
|
AVFILTER_FLAG_SLICE_THREADS
,
};
};
#endif
#endif
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