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
2e219b49
Commit
2e219b49
authored
May 19, 2016
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hwcontext_cuda: implement device creation
parent
38392b2a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
hwcontext_cuda.c
libavutil/hwcontext_cuda.c
+44
-0
No files found.
libavutil/hwcontext_cuda.c
View file @
2e219b49
...
@@ -253,6 +253,49 @@ static int cuda_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst,
...
@@ -253,6 +253,49 @@ static int cuda_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst,
return
0
;
return
0
;
}
}
static
void
cuda_device_free
(
AVHWDeviceContext
*
ctx
)
{
AVCUDADeviceContext
*
hwctx
=
ctx
->
hwctx
;
cuCtxDestroy
(
hwctx
->
cuda_ctx
);
}
static
int
cuda_device_create
(
AVHWDeviceContext
*
ctx
,
const
char
*
device
,
AVDictionary
*
opts
,
int
flags
)
{
AVCUDADeviceContext
*
hwctx
=
ctx
->
hwctx
;
CUdevice
cu_device
;
CUcontext
dummy
;
CUresult
err
;
int
device_idx
=
0
;
if
(
device
)
device_idx
=
strtol
(
device
,
NULL
,
0
);
err
=
cuInit
(
0
);
if
(
err
!=
CUDA_SUCCESS
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Could not initialize the CUDA driver API
\n
"
);
return
AVERROR_UNKNOWN
;
}
err
=
cuDeviceGet
(
&
cu_device
,
device_idx
);
if
(
err
!=
CUDA_SUCCESS
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Could not get the device number %d
\n
"
,
device_idx
);
return
AVERROR_UNKNOWN
;
}
err
=
cuCtxCreate
(
&
hwctx
->
cuda_ctx
,
0
,
cu_device
);
if
(
err
!=
CUDA_SUCCESS
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Error creating a CUDA context
\n
"
);
return
AVERROR_UNKNOWN
;
}
cuCtxPopCurrent
(
&
dummy
);
ctx
->
free
=
cuda_device_free
;
return
0
;
}
const
HWContextType
ff_hwcontext_type_cuda
=
{
const
HWContextType
ff_hwcontext_type_cuda
=
{
.
type
=
AV_HWDEVICE_TYPE_CUDA
,
.
type
=
AV_HWDEVICE_TYPE_CUDA
,
.
name
=
"CUDA"
,
.
name
=
"CUDA"
,
...
@@ -260,6 +303,7 @@ const HWContextType ff_hwcontext_type_cuda = {
...
@@ -260,6 +303,7 @@ const HWContextType ff_hwcontext_type_cuda = {
.
device_hwctx_size
=
sizeof
(
AVCUDADeviceContext
),
.
device_hwctx_size
=
sizeof
(
AVCUDADeviceContext
),
.
frames_priv_size
=
sizeof
(
CUDAFramesContext
),
.
frames_priv_size
=
sizeof
(
CUDAFramesContext
),
.
device_create
=
cuda_device_create
,
.
frames_init
=
cuda_frames_init
,
.
frames_init
=
cuda_frames_init
,
.
frames_get_buffer
=
cuda_get_buffer
,
.
frames_get_buffer
=
cuda_get_buffer
,
.
transfer_get_formats
=
cuda_transfer_get_formats
,
.
transfer_get_formats
=
cuda_transfer_get_formats
,
...
...
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