Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
B1ack1e
FFmpeg
提交
f72db3f2
F
FFmpeg
项目概览
B1ack1e
/
FFmpeg
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
FFmpeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f72db3f2
编写于
5月 19, 2016
作者:
A
Anton Khirnov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
avconv_vdpau: use the hwcontext device creation API
上级
b8bf9194
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
7 addition
and
88 deletion
+7
-88
avconv_vdpau.c
avconv_vdpau.c
+7
-88
未找到文件。
avconv_vdpau.c
浏览文件 @
f72db3f2
...
...
@@ -18,11 +18,6 @@
#include <stdint.h>
#include <vdpau/vdpau.h>
#include <vdpau/vdpau_x11.h>
#include <X11/Xlib.h>
#include "avconv.h"
#include "libavcodec/vdpau.h"
...
...
@@ -38,23 +33,6 @@ typedef struct VDPAUContext {
AVFrame
*
tmp_frame
;
}
VDPAUContext
;
typedef
struct
VDPAUHWDevicePriv
{
VdpDeviceDestroy
*
device_destroy
;
Display
*
dpy
;
}
VDPAUHWDevicePriv
;
static
void
device_free
(
AVHWDeviceContext
*
ctx
)
{
AVVDPAUDeviceContext
*
hwctx
=
ctx
->
hwctx
;
VDPAUHWDevicePriv
*
priv
=
ctx
->
user_opaque
;
if
(
priv
->
device_destroy
)
priv
->
device_destroy
(
hwctx
->
device
);
if
(
priv
->
dpy
)
XCloseDisplay
(
priv
->
dpy
);
av_freep
(
&
priv
);
}
static
void
vdpau_uninit
(
AVCodecContext
*
s
)
{
InputStream
*
ist
=
s
->
opaque
;
...
...
@@ -106,15 +84,8 @@ static int vdpau_alloc(AVCodecContext *s)
InputStream
*
ist
=
s
->
opaque
;
int
loglevel
=
(
ist
->
hwaccel_id
==
HWACCEL_AUTO
)
?
AV_LOG_VERBOSE
:
AV_LOG_ERROR
;
VDPAUContext
*
ctx
;
const
char
*
display
,
*
vendor
;
VdpStatus
err
;
int
ret
;
VdpDevice
device
;
VdpGetProcAddress
*
get_proc_address
;
VdpGetInformationString
*
get_information_string
;
VDPAUHWDevicePriv
*
device_priv
=
NULL
;
AVBufferRef
*
device_ref
=
NULL
;
AVHWDeviceContext
*
device_ctx
;
AVVDPAUDeviceContext
*
device_hwctx
;
...
...
@@ -124,10 +95,6 @@ static int vdpau_alloc(AVCodecContext *s)
if
(
!
ctx
)
return
AVERROR
(
ENOMEM
);
device_priv
=
av_mallocz
(
sizeof
(
*
device_priv
));
if
(
!
device_priv
)
goto
fail
;
ist
->
hwaccel_ctx
=
ctx
;
ist
->
hwaccel_uninit
=
vdpau_uninit
;
ist
->
hwaccel_get_buffer
=
vdpau_get_buffer
;
...
...
@@ -137,51 +104,12 @@ static int vdpau_alloc(AVCodecContext *s)
if
(
!
ctx
->
tmp_frame
)
goto
fail
;
device_priv
->
dpy
=
XOpenDisplay
(
ist
->
hwaccel_device
);
if
(
!
device_priv
->
dpy
)
{
av_log
(
NULL
,
loglevel
,
"Cannot open the X11 display %s.
\n
"
,
XDisplayName
(
ist
->
hwaccel_device
));
goto
fail
;
}
display
=
XDisplayString
(
device_priv
->
dpy
);
err
=
vdp_device_create_x11
(
device_priv
->
dpy
,
XDefaultScreen
(
device_priv
->
dpy
),
&
device
,
&
get_proc_address
);
if
(
err
!=
VDP_STATUS_OK
)
{
av_log
(
NULL
,
loglevel
,
"VDPAU device creation on X11 display %s failed.
\n
"
,
display
);
goto
fail
;
}
#define GET_CALLBACK(id, result) \
do { \
void *tmp; \
err = get_proc_address(device, id, &tmp); \
if (err != VDP_STATUS_OK) { \
av_log(NULL, loglevel, "Error getting the " #id " callback.\n"); \
goto fail; \
} \
result = tmp; \
} while (0)
GET_CALLBACK
(
VDP_FUNC_ID_GET_INFORMATION_STRING
,
get_information_string
);
GET_CALLBACK
(
VDP_FUNC_ID_DEVICE_DESTROY
,
device_priv
->
device_destroy
);
device_ref
=
av_hwdevice_ctx_alloc
(
AV_HWDEVICE_TYPE_VDPAU
);
if
(
!
device_ref
)
goto
fail
;
device_ctx
=
(
AVHWDeviceContext
*
)
device_ref
->
data
;
device_hwctx
=
device_ctx
->
hwctx
;
device_ctx
->
user_opaque
=
device_priv
;
device_ctx
->
free
=
device_free
;
device_hwctx
->
device
=
device
;
device_hwctx
->
get_proc_address
=
get_proc_address
;
device_priv
=
NULL
;
ret
=
av_hwdevice_ctx_init
(
device_ref
);
ret
=
av_hwdevice_ctx_create
(
&
device_ref
,
AV_HWDEVICE_TYPE_VDPAU
,
ist
->
hwaccel_device
,
NULL
,
0
);
if
(
ret
<
0
)
goto
fail
;
device_ctx
=
(
AVHWDeviceContext
*
)
device_ref
->
data
;
device_hwctx
=
device_ctx
->
hwctx
;
ctx
->
hw_frames_ctx
=
av_hwframe_ctx_alloc
(
device_ref
);
if
(
!
ctx
->
hw_frames_ctx
)
...
...
@@ -198,26 +126,17 @@ do {
if
(
ret
<
0
)
goto
fail
;
if
(
av_vdpau_bind_context
(
s
,
device
,
get_proc_address
,
0
))
if
(
av_vdpau_bind_context
(
s
,
device
_hwctx
->
device
,
device_hwctx
->
get_proc_address
,
0
))
goto
fail
;
get_information_string
(
&
vendor
);
av_log
(
NULL
,
AV_LOG_VERBOSE
,
"Using VDPAU -- %s -- on X11 display %s, "
"to decode input stream #%d:%d.
\n
"
,
vendor
,
display
,
ist
->
file_index
,
ist
->
st
->
index
);
av_log
(
NULL
,
AV_LOG_VERBOSE
,
"Using VDPAU to decode input stream #%d:%d.
\n
"
,
ist
->
file_index
,
ist
->
st
->
index
);
return
0
;
fail:
av_log
(
NULL
,
loglevel
,
"VDPAU init failed for stream #%d:%d.
\n
"
,
ist
->
file_index
,
ist
->
st
->
index
);
if
(
device_priv
)
{
if
(
device_priv
->
device_destroy
)
device_priv
->
device_destroy
(
device
);
if
(
device_priv
->
dpy
)
XCloseDisplay
(
device_priv
->
dpy
);
}
av_freep
(
&
device_priv
);
av_buffer_unref
(
&
device_ref
);
vdpau_uninit
(
s
);
return
AVERROR
(
EINVAL
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录