Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
32ba563c
F
Ffmpeg
项目概览
小白菜888
/
Ffmpeg
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Ffmpeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
32ba563c
编写于
11月 18, 2019
作者:
O
Oleg Dobkin
提交者:
Timo Rothenpieler
11月 26, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
avutil/hwcontext_cuda: allow using primary CUDA device context
Signed-off-by:
N
Timo Rothenpieler
<
timo@rothenpieler.org
>
上级
59d264b0
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
63 addition
and
15 deletion
+63
-15
configure
configure
+4
-4
libavutil/hwcontext_cuda.c
libavutil/hwcontext_cuda.c
+39
-10
libavutil/hwcontext_cuda.h
libavutil/hwcontext_cuda.h
+17
-0
libavutil/hwcontext_cuda_internal.h
libavutil/hwcontext_cuda_internal.h
+2
-0
libavutil/version.h
libavutil/version.h
+1
-1
未找到文件。
configure
浏览文件 @
32ba563c
...
...
@@ -6139,10 +6139,10 @@ fi
if
!
disabled ffnvcodec
;
then
ffnv_hdr_list
=
"ffnvcodec/nvEncodeAPI.h ffnvcodec/dynlink_cuda.h ffnvcodec/dynlink_cuviddec.h ffnvcodec/dynlink_nvcuvid.h"
check_pkg_config ffnvcodec
"ffnvcodec >= 9.
0.18.0
"
"
$ffnv_hdr_list
"
""
||
\
check_pkg_config ffnvcodec
"ffnvcodec >=
8.2.15.8 ffnvcodec < 8.3
"
"
$ffnv_hdr_list
"
""
||
\
check_pkg_config ffnvcodec
"ffnvcodec >= 8.
1.24.9 ffnvcodec < 8.2
"
"
$ffnv_hdr_list
"
""
||
\
check_pkg_config ffnvcodec
"ffnvcodec >= 8.
0.14.9 ffnvcodec < 8.1
"
"
$ffnv_hdr_list
"
""
check_pkg_config ffnvcodec
"ffnvcodec >= 9.
1.23.1
"
"
$ffnv_hdr_list
"
""
||
\
check_pkg_config ffnvcodec
"ffnvcodec >=
9.0.18.3 ffnvcodec < 9.1
"
"
$ffnv_hdr_list
"
""
||
\
check_pkg_config ffnvcodec
"ffnvcodec >= 8.
2.15.10 ffnvcodec < 8.3
"
"
$ffnv_hdr_list
"
""
||
\
check_pkg_config ffnvcodec
"ffnvcodec >= 8.
1.24.11 ffnvcodec < 8.2
"
"
$ffnv_hdr_list
"
""
fi
check_cpp_condition winrt windows.h
"!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)"
...
...
libavutil/hwcontext_cuda.c
浏览文件 @
32ba563c
...
...
@@ -280,10 +280,16 @@ static void cuda_device_uninit(AVHWDeviceContext *device_ctx)
if
(
hwctx
->
internal
)
{
CudaFunctions
*
cu
=
hwctx
->
internal
->
cuda_dl
;
if
(
hwctx
->
internal
->
is_allocated
&&
hwctx
->
cuda_ctx
)
{
CHECK_CU
(
cu
->
cuCtxDestroy
(
hwctx
->
cuda_ctx
));
if
(
hwctx
->
internal
->
flags
&
AV_CUDA_USE_PRIMARY_CONTEXT
)
CHECK_CU
(
cu
->
cuDevicePrimaryCtxRelease
(
hwctx
->
internal
->
cuda_device
));
else
CHECK_CU
(
cu
->
cuCtxDestroy
(
hwctx
->
cuda_ctx
));
hwctx
->
cuda_ctx
=
NULL
;
}
cuda_free_functions
(
&
hwctx
->
internal
->
cuda_dl
);
}
...
...
@@ -322,9 +328,11 @@ static int cuda_device_create(AVHWDeviceContext *device_ctx,
{
AVCUDADeviceContext
*
hwctx
=
device_ctx
->
hwctx
;
CudaFunctions
*
cu
;
CUdevice
cu_device
;
CUcontext
dummy
;
int
ret
,
device_idx
=
0
;
int
ret
,
dev_active
=
0
,
device_idx
=
0
;
unsigned
int
dev_flags
=
0
;
const
unsigned
int
desired_flags
=
CU_CTX_SCHED_BLOCKING_SYNC
;
if
(
device
)
device_idx
=
strtol
(
device
,
NULL
,
0
);
...
...
@@ -338,21 +346,42 @@ static int cuda_device_create(AVHWDeviceContext *device_ctx,
if
(
ret
<
0
)
goto
error
;
ret
=
CHECK_CU
(
cu
->
cuDeviceGet
(
&
cu
_device
,
device_idx
));
ret
=
CHECK_CU
(
cu
->
cuDeviceGet
(
&
hwctx
->
internal
->
cuda
_device
,
device_idx
));
if
(
ret
<
0
)
goto
error
;
ret
=
CHECK_CU
(
cu
->
cuCtxCreate
(
&
hwctx
->
cuda_ctx
,
CU_CTX_SCHED_BLOCKING_SYNC
,
cu_device
));
if
(
ret
<
0
)
goto
error
;
hwctx
->
internal
->
flags
=
flags
;
// Setting stream to NULL will make functions automatically use the default CUstream
hwctx
->
stream
=
NULL
;
if
(
flags
&
AV_CUDA_USE_PRIMARY_CONTEXT
)
{
ret
=
CHECK_CU
(
cu
->
cuDevicePrimaryCtxGetState
(
hwctx
->
internal
->
cuda_device
,
&
dev_flags
,
&
dev_active
));
if
(
ret
<
0
)
goto
error
;
CHECK_CU
(
cu
->
cuCtxPopCurrent
(
&
dummy
));
if
(
dev_active
&&
dev_flags
!=
desired_flags
)
{
av_log
(
device_ctx
,
AV_LOG_ERROR
,
"Primary context already active with incompatible flags.
\n
"
);
goto
error
;
}
else
if
(
dev_flags
!=
desired_flags
)
{
ret
=
CHECK_CU
(
cu
->
cuDevicePrimaryCtxSetFlags
(
hwctx
->
internal
->
cuda_device
,
desired_flags
));
if
(
ret
<
0
)
goto
error
;
}
ret
=
CHECK_CU
(
cu
->
cuDevicePrimaryCtxRetain
(
&
hwctx
->
cuda_ctx
,
hwctx
->
internal
->
cuda_device
));
if
(
ret
<
0
)
goto
error
;
}
else
{
ret
=
CHECK_CU
(
cu
->
cuCtxCreate
(
&
hwctx
->
cuda_ctx
,
desired_flags
,
hwctx
->
internal
->
cuda_device
));
if
(
ret
<
0
)
goto
error
;
CHECK_CU
(
cu
->
cuCtxPopCurrent
(
&
dummy
));
}
hwctx
->
internal
->
is_allocated
=
1
;
// Setting stream to NULL will make functions automatically use the default CUstream
hwctx
->
stream
=
NULL
;
return
0
;
error:
...
...
libavutil/hwcontext_cuda.h
浏览文件 @
32ba563c
...
...
@@ -49,4 +49,21 @@ typedef struct AVCUDADeviceContext {
* AVHWFramesContext.hwctx is currently not used
*/
/**
* @defgroup hwcontext_cuda Device context creation flags
*
* Flags for av_hwdevice_ctx_create.
*
* @{
*/
/**
* Use primary device context instead of creating a new one.
*/
#define AV_CUDA_USE_PRIMARY_CONTEXT (1 << 0)
/**
* @}
*/
#endif
/* AVUTIL_HWCONTEXT_CUDA_H */
libavutil/hwcontext_cuda_internal.h
浏览文件 @
32ba563c
...
...
@@ -31,6 +31,8 @@
struct
AVCUDADeviceContextInternal
{
CudaFunctions
*
cuda_dl
;
int
is_allocated
;
CUdevice
cuda_device
;
int
flags
;
};
#endif
/* AVUTIL_HWCONTEXT_CUDA_INTERNAL_H */
...
...
libavutil/version.h
浏览文件 @
32ba563c
...
...
@@ -80,7 +80,7 @@
#define LIBAVUTIL_VERSION_MAJOR 56
#define LIBAVUTIL_VERSION_MINOR 36
#define LIBAVUTIL_VERSION_MICRO 10
0
#define LIBAVUTIL_VERSION_MICRO 10
1
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录