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
b02f073a
Commit
b02f073a
authored
May 06, 2013
by
highgod0401
Committed by
Michael Niedermayer
May 06, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi/deshake_opencl: use ff_opencl_set_parameter
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
0b5f4fdc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
34 deletions
+31
-34
deshake_opencl.c
libavfilter/deshake_opencl.c
+31
-34
No files found.
libavfilter/deshake_opencl.c
View file @
b02f073a
...
...
@@ -27,64 +27,61 @@
#include "libavutil/dict.h"
#include "libavutil/pixdesc.h"
#include "deshake_opencl.h"
#include "libavutil/opencl_internal.h"
#define MATRIX_SIZE 6
#define PLANE_NUM 3
#define TRANSFORM_OPENCL_CHECK(method, ...) \
status = method(__VA_ARGS__); \
if (status != CL_SUCCESS) { \
av_log(ctx, AV_LOG_ERROR, "error %s %d\n", # method, status); \
return AVERROR_EXTERNAL; \
}
#define TRANSFORM_OPENCL_SET_KERNEL_ARG(arg_ptr) \
status = clSetKernelArg((kernel),(arg_no++),(sizeof(arg_ptr)),(void*)(&(arg_ptr))); \
if (status != CL_SUCCESS) { \
av_log(ctx, AV_LOG_ERROR, "cannot set kernel argument: %d\n", status ); \
return AVERROR_EXTERNAL; \
}
int
ff_opencl_transform
(
AVFilterContext
*
ctx
,
int
width
,
int
height
,
int
cw
,
int
ch
,
const
float
*
matrix_y
,
const
float
*
matrix_uv
,
enum
InterpolateMethod
interpolate
,
enum
FillMethod
fill
,
AVFrame
*
in
,
AVFrame
*
out
)
{
int
arg_no
,
ret
=
0
;
int
ret
=
0
;
const
size_t
global_work_size
=
width
*
height
+
2
*
ch
*
cw
;
cl_kernel
kernel
;
cl_int
status
;
DeshakeContext
*
deshake
=
ctx
->
priv
;
FFOpenclParam
opencl_param
=
{
0
};
opencl_param
.
ctx
=
ctx
;
opencl_param
.
kernel
=
deshake
->
opencl_ctx
.
kernel_env
.
kernel
;
ret
=
av_opencl_buffer_write
(
deshake
->
opencl_ctx
.
cl_matrix_y
,
(
uint8_t
*
)
matrix_y
,
deshake
->
opencl_ctx
.
matrix_size
*
sizeof
(
cl_float
));
if
(
ret
<
0
)
return
ret
;
ret
=
av_opencl_buffer_write
(
deshake
->
opencl_ctx
.
cl_matrix_uv
,
(
uint8_t
*
)
matrix_uv
,
deshake
->
opencl_ctx
.
matrix_size
*
sizeof
(
cl_float
));
if
(
ret
<
0
)
return
ret
;
kernel
=
deshake
->
opencl_ctx
.
kernel_env
.
kernel
;
arg_no
=
0
;
if
((
unsigned
int
)
interpolate
>
INTERPOLATE_BIQUADRATIC
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Selected interpolate method is invalid
\n
"
);
return
AVERROR
(
EINVAL
);
}
TRANSFORM_OPENCL_SET_KERNEL_ARG
(
deshake
->
opencl_ctx
.
cl_inbuf
);
TRANSFORM_OPENCL_SET_KERNEL_ARG
(
deshake
->
opencl_ctx
.
cl_outbuf
);
TRANSFORM_OPENCL_SET_KERNEL_ARG
(
deshake
->
opencl_ctx
.
cl_matrix_y
);
TRANSFORM_OPENCL_SET_KERNEL_ARG
(
deshake
->
opencl_ctx
.
cl_matrix_uv
);
TRANSFORM_OPENCL_SET_KERNEL_ARG
(
interpolate
);
TRANSFORM_OPENCL_SET_KERNEL_ARG
(
fill
);
TRANSFORM_OPENCL_SET_KERNEL_ARG
(
in
->
linesize
[
0
]);
TRANSFORM_OPENCL_SET_KERNEL_ARG
(
out
->
linesize
[
0
]);
TRANSFORM_OPENCL_SET_KERNEL_ARG
(
in
->
linesize
[
1
]);
TRANSFORM_OPENCL_SET_KERNEL_ARG
(
out
->
linesize
[
1
]);
TRANSFORM_OPENCL_SET_KERNEL_ARG
(
height
);
TRANSFORM_OPENCL_SET_KERNEL_ARG
(
width
);
TRANSFORM_OPENCL_SET_KERNEL_ARG
(
ch
);
TRANSFORM_OPENCL_SET_KERNEL_ARG
(
cw
);
TRANSFORM_OPENCL_CHECK
(
clEnqueueNDRangeKernel
,
deshake
->
opencl_ctx
.
kernel_env
.
command_queue
,
deshake
->
opencl_ctx
.
kernel_env
.
kernel
,
1
,
NULL
,
ret
=
ff_opencl_set_parameter
(
&
opencl_param
,
FF_OPENCL_PARAM_INFO
(
deshake
->
opencl_ctx
.
cl_inbuf
),
FF_OPENCL_PARAM_INFO
(
deshake
->
opencl_ctx
.
cl_outbuf
),
FF_OPENCL_PARAM_INFO
(
deshake
->
opencl_ctx
.
cl_matrix_y
),
FF_OPENCL_PARAM_INFO
(
deshake
->
opencl_ctx
.
cl_matrix_uv
),
FF_OPENCL_PARAM_INFO
(
interpolate
),
FF_OPENCL_PARAM_INFO
(
fill
),
FF_OPENCL_PARAM_INFO
(
in
->
linesize
[
0
]),
FF_OPENCL_PARAM_INFO
(
out
->
linesize
[
0
]),
FF_OPENCL_PARAM_INFO
(
in
->
linesize
[
1
]),
FF_OPENCL_PARAM_INFO
(
out
->
linesize
[
1
]),
FF_OPENCL_PARAM_INFO
(
height
),
FF_OPENCL_PARAM_INFO
(
width
),
FF_OPENCL_PARAM_INFO
(
ch
),
FF_OPENCL_PARAM_INFO
(
cw
),
NULL
);
if
(
ret
<
0
)
return
ret
;
status
=
clEnqueueNDRangeKernel
(
deshake
->
opencl_ctx
.
kernel_env
.
command_queue
,
deshake
->
opencl_ctx
.
kernel_env
.
kernel
,
1
,
NULL
,
&
global_work_size
,
NULL
,
0
,
NULL
,
NULL
);
if
(
status
!=
CL_SUCCESS
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"OpenCL run kernel error occurred: %s
\n
"
,
av_opencl_errstr
(
status
));
return
AVERROR_EXTERNAL
;
}
clFinish
(
deshake
->
opencl_ctx
.
kernel_env
.
command_queue
);
ret
=
av_opencl_buffer_read_image
(
out
->
data
,
deshake
->
opencl_ctx
.
out_plane_size
,
deshake
->
opencl_ctx
.
plane_num
,
deshake
->
opencl_ctx
.
cl_outbuf
,
...
...
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