Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
b0ca90d7
Commit
b0ca90d7
authored
8 years ago
by
Timo Rothenpieler
Browse files
Options
Downloads
Patches
Plain Diff
avfilter/vf_hwupload_cuda: use new hwdevice allocation API
parent
a66835bc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libavfilter/vf_hwupload_cuda.c
+5
-52
5 additions, 52 deletions
libavfilter/vf_hwupload_cuda.c
with
5 additions
and
52 deletions
libavfilter/vf_hwupload_cuda.c
+
5
−
52
View file @
b0ca90d7
...
@@ -18,7 +18,6 @@
...
@@ -18,7 +18,6 @@
#include
"libavutil/buffer.h"
#include
"libavutil/buffer.h"
#include
"libavutil/hwcontext.h"
#include
"libavutil/hwcontext.h"
#include
"libavutil/hwcontext_cuda.h"
#include
"libavutil/log.h"
#include
"libavutil/log.h"
#include
"libavutil/opt.h"
#include
"libavutil/opt.h"
...
@@ -35,60 +34,14 @@ typedef struct CudaUploadContext {
...
@@ -35,60 +34,14 @@ typedef struct CudaUploadContext {
AVBufferRef
*
hwframe
;
AVBufferRef
*
hwframe
;
}
CudaUploadContext
;
}
CudaUploadContext
;
static
void
cudaupload_ctx_free
(
AVHWDeviceContext
*
ctx
)
{
AVCUDADeviceContext
*
hwctx
=
ctx
->
hwctx
;
cuCtxDestroy
(
hwctx
->
cuda_ctx
);
}
static
av_cold
int
cudaupload_init
(
AVFilterContext
*
ctx
)
static
av_cold
int
cudaupload_init
(
AVFilterContext
*
ctx
)
{
{
CudaUploadContext
*
s
=
ctx
->
priv
;
CudaUploadContext
*
s
=
ctx
->
priv
;
char
buf
[
64
]
=
{
0
};
AVHWDeviceContext
*
device_ctx
;
snprintf
(
buf
,
sizeof
(
buf
),
"%d"
,
s
->
device_idx
);
AVCUDADeviceContext
*
device_hwctx
;
CUdevice
device
;
CUcontext
cuda_ctx
=
NULL
,
dummy
;
CUresult
err
;
int
ret
;
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
(
&
device
,
s
->
device_idx
);
if
(
err
!=
CUDA_SUCCESS
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Could not get the device number %d
\n
"
,
s
->
device_idx
);
return
AVERROR_UNKNOWN
;
}
err
=
cuCtxCreate
(
&
cuda_ctx
,
0
,
device
);
if
(
err
!=
CUDA_SUCCESS
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Error creating a CUDA context
\n
"
);
return
AVERROR_UNKNOWN
;
}
cuCtxPopCurrent
(
&
dummy
);
s
->
hwdevice
=
av_hwdevice_ctx_alloc
(
AV_HWDEVICE_TYPE_CUDA
);
if
(
!
s
->
hwdevice
)
{
cuCtxDestroy
(
cuda_ctx
);
return
AVERROR
(
ENOMEM
);
}
device_ctx
=
(
AVHWDeviceContext
*
)
s
->
hwdevice
->
data
;
device_ctx
->
free
=
cudaupload_ctx_free
;
device_hwctx
=
device_ctx
->
hwctx
;
return
av_hwdevice_ctx_create
(
&
s
->
hwdevice
,
AV_HWDEVICE_TYPE_CUDA
,
buf
,
NULL
,
0
);
device_hwctx
->
cuda_ctx
=
cuda_ctx
;
ret
=
av_hwdevice_ctx_init
(
s
->
hwdevice
);
if
(
ret
<
0
)
return
ret
;
return
0
;
}
}
static
av_cold
void
cudaupload_uninit
(
AVFilterContext
*
ctx
)
static
av_cold
void
cudaupload_uninit
(
AVFilterContext
*
ctx
)
...
@@ -134,8 +87,8 @@ static int cudaupload_config_output(AVFilterLink *outlink)
...
@@ -134,8 +87,8 @@ static int cudaupload_config_output(AVFilterLink *outlink)
hwframe_ctx
=
(
AVHWFramesContext
*
)
s
->
hwframe
->
data
;
hwframe_ctx
=
(
AVHWFramesContext
*
)
s
->
hwframe
->
data
;
hwframe_ctx
->
format
=
AV_PIX_FMT_CUDA
;
hwframe_ctx
->
format
=
AV_PIX_FMT_CUDA
;
hwframe_ctx
->
sw_format
=
inlink
->
format
;
hwframe_ctx
->
sw_format
=
inlink
->
format
;
hwframe_ctx
->
width
=
FFALIGN
(
inlink
->
w
,
16
)
;
hwframe_ctx
->
width
=
inlink
->
w
;
hwframe_ctx
->
height
=
FFALIGN
(
inlink
->
h
,
16
)
;
hwframe_ctx
->
height
=
inlink
->
h
;
ret
=
av_hwframe_ctx_init
(
s
->
hwframe
);
ret
=
av_hwframe_ctx_init
(
s
->
hwframe
);
if
(
ret
<
0
)
if
(
ret
<
0
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment