Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
202b59cd
Commit
202b59cd
authored
Jan 02, 2018
by
Mark Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi/opencl: Use filter device if no input device is available
This allows implementing sources as well as filters.
parent
6874945f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
6 deletions
+33
-6
opencl.c
libavfilter/opencl.c
+33
-6
No files found.
libavfilter/opencl.c
View file @
202b59cd
...
@@ -42,11 +42,29 @@ int ff_opencl_filter_query_formats(AVFilterContext *avctx)
...
@@ -42,11 +42,29 @@ int ff_opencl_filter_query_formats(AVFilterContext *avctx)
return
ff_set_common_formats
(
avctx
,
formats
);
return
ff_set_common_formats
(
avctx
,
formats
);
}
}
static
int
opencl_filter_set_device
(
AVFilterContext
*
avctx
,
AVBufferRef
*
device
)
{
OpenCLFilterContext
*
ctx
=
avctx
->
priv
;
av_buffer_unref
(
&
ctx
->
device_ref
);
ctx
->
device_ref
=
av_buffer_ref
(
device
);
if
(
!
ctx
->
device_ref
)
return
AVERROR
(
ENOMEM
);
ctx
->
device
=
(
AVHWDeviceContext
*
)
ctx
->
device_ref
->
data
;
ctx
->
hwctx
=
ctx
->
device
->
hwctx
;
return
0
;
}
int
ff_opencl_filter_config_input
(
AVFilterLink
*
inlink
)
int
ff_opencl_filter_config_input
(
AVFilterLink
*
inlink
)
{
{
AVFilterContext
*
avctx
=
inlink
->
dst
;
AVFilterContext
*
avctx
=
inlink
->
dst
;
OpenCLFilterContext
*
ctx
=
avctx
->
priv
;
OpenCLFilterContext
*
ctx
=
avctx
->
priv
;
AVHWFramesContext
*
input_frames
;
AVHWFramesContext
*
input_frames
;
int
err
;
if
(
!
inlink
->
hw_frames_ctx
)
{
if
(
!
inlink
->
hw_frames_ctx
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"OpenCL filtering requires a "
av_log
(
avctx
,
AV_LOG_ERROR
,
"OpenCL filtering requires a "
...
@@ -59,15 +77,12 @@ int ff_opencl_filter_config_input(AVFilterLink *inlink)
...
@@ -59,15 +77,12 @@ int ff_opencl_filter_config_input(AVFilterLink *inlink)
return
0
;
return
0
;
input_frames
=
(
AVHWFramesContext
*
)
inlink
->
hw_frames_ctx
->
data
;
input_frames
=
(
AVHWFramesContext
*
)
inlink
->
hw_frames_ctx
->
data
;
if
(
input_frames
->
format
!=
AV_PIX_FMT_OPENCL
)
if
(
input_frames
->
format
!=
AV_PIX_FMT_OPENCL
)
return
AVERROR
(
EINVAL
);
return
AVERROR
(
EINVAL
);
ctx
->
device_ref
=
av_buffer_ref
(
input_frames
->
device_ref
);
err
=
opencl_filter_set_device
(
avctx
,
input_frames
->
device_ref
);
if
(
!
ctx
->
device_ref
)
if
(
err
<
0
)
return
AVERROR
(
ENOMEM
);
return
err
;
ctx
->
device
=
input_frames
->
device_ctx
;
ctx
->
hwctx
=
ctx
->
device
->
hwctx
;
// Default output parameters match input parameters.
// Default output parameters match input parameters.
if
(
ctx
->
output_format
==
AV_PIX_FMT_NONE
)
if
(
ctx
->
output_format
==
AV_PIX_FMT_NONE
)
...
@@ -90,6 +105,18 @@ int ff_opencl_filter_config_output(AVFilterLink *outlink)
...
@@ -90,6 +105,18 @@ int ff_opencl_filter_config_output(AVFilterLink *outlink)
av_buffer_unref
(
&
outlink
->
hw_frames_ctx
);
av_buffer_unref
(
&
outlink
->
hw_frames_ctx
);
if
(
!
ctx
->
device_ref
)
{
if
(
!
avctx
->
hw_device_ctx
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"OpenCL filtering requires an "
"OpenCL device.
\n
"
);
return
AVERROR
(
EINVAL
);
}
err
=
opencl_filter_set_device
(
avctx
,
avctx
->
hw_device_ctx
);
if
(
err
<
0
)
return
err
;
}
output_frames_ref
=
av_hwframe_ctx_alloc
(
ctx
->
device_ref
);
output_frames_ref
=
av_hwframe_ctx_alloc
(
ctx
->
device_ref
);
if
(
!
output_frames_ref
)
{
if
(
!
output_frames_ref
)
{
err
=
AVERROR
(
ENOMEM
);
err
=
AVERROR
(
ENOMEM
);
...
...
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