Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
916b3b90
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,体验更适合开发者的 AI 搜索 >>
提交
916b3b90
编写于
12月 20, 2018
作者:
M
Mark Thompson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
vaapi_encode_vp9: Support more complex reference structures
上级
362992e9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
51 addition
and
53 deletion
+51
-53
libavcodec/vaapi_encode_vp9.c
libavcodec/vaapi_encode_vp9.c
+51
-53
未找到文件。
libavcodec/vaapi_encode_vp9.c
浏览文件 @
916b3b90
...
...
@@ -32,6 +32,10 @@
#define VP9_MAX_QUANT 255
typedef
struct
VAAPIEncodeVP9Picture
{
int
slot
;
}
VAAPIEncodeVP9Picture
;
typedef
struct
VAAPIEncodeVP9Context
{
VAAPIEncodeContext
common
;
...
...
@@ -43,22 +47,9 @@ typedef struct VAAPIEncodeVP9Context {
int
q_idx_idr
;
int
q_idx_p
;
int
q_idx_b
;
// Stream state.
// Reference direction for B-like frames:
// 0 - most recent P/IDR frame is last.
// 1 - most recent P frame is golden.
int
last_ref_dir
;
}
VAAPIEncodeVP9Context
;
#define vseq_var(name) vseq->name, name
#define vseq_field(name) vseq->seq_fields.bits.name, name
#define vpic_var(name) vpic->name, name
#define vpic_field(name) vpic->pic_fields.bits.name, name
static
int
vaapi_encode_vp9_init_sequence_params
(
AVCodecContext
*
avctx
)
{
VAAPIEncodeContext
*
ctx
=
avctx
->
priv_data
;
...
...
@@ -88,6 +79,7 @@ static int vaapi_encode_vp9_init_picture_params(AVCodecContext *avctx,
{
VAAPIEncodeContext
*
ctx
=
avctx
->
priv_data
;
VAAPIEncodeVP9Context
*
priv
=
avctx
->
priv_data
;
VAAPIEncodeVP9Picture
*
hpic
=
pic
->
priv_data
;
VAEncPictureParameterBufferVP9
*
vpic
=
pic
->
codec_picture_params
;
int
i
;
...
...
@@ -98,65 +90,71 @@ static int vaapi_encode_vp9_init_picture_params(AVCodecContext *avctx,
case
PICTURE_TYPE_IDR
:
av_assert0
(
pic
->
nb_refs
==
0
);
vpic
->
ref_flags
.
bits
.
force_kf
=
1
;
vpic
->
refresh_frame_flags
=
0x
01
;
priv
->
last_ref_dir
=
0
;
vpic
->
refresh_frame_flags
=
0x
ff
;
hpic
->
slot
=
0
;
break
;
case
PICTURE_TYPE_P
:
av_assert0
(
pic
->
nb_refs
==
1
);
if
(
ctx
->
b_per_p
>
0
)
{
if
(
priv
->
last_ref_dir
)
{
vpic
->
ref_flags
.
bits
.
ref_frame_ctrl_l0
=
2
;
vpic
->
ref_flags
.
bits
.
ref_gf_idx
=
1
;
vpic
->
ref_flags
.
bits
.
ref_gf_sign_bias
=
1
;
vpic
->
refresh_frame_flags
=
0x01
;
{
VAAPIEncodeVP9Picture
*
href
=
pic
->
refs
[
0
]
->
priv_data
;
av_assert0
(
href
->
slot
==
0
||
href
->
slot
==
1
);
if
(
ctx
->
max_b_depth
>
0
)
{
hpic
->
slot
=
!
href
->
slot
;
vpic
->
refresh_frame_flags
=
1
<<
hpic
->
slot
|
0xfc
;
}
else
{
vpic
->
ref_flags
.
bits
.
ref_frame_ctrl_l0
=
1
;
vpic
->
ref_flags
.
bits
.
ref_last_idx
=
0
;
vpic
->
ref_flags
.
bits
.
ref_last_sign_bias
=
1
;
vpic
->
refresh_frame_flags
=
0x02
;
hpic
->
slot
=
0
;
vpic
->
refresh_frame_flags
=
0xff
;
}
}
else
{
vpic
->
ref_flags
.
bits
.
ref_frame_ctrl_l0
=
1
;
vpic
->
ref_flags
.
bits
.
ref_last_idx
=
0
;
vpic
->
ref_flags
.
bits
.
ref_last_idx
=
href
->
slot
;
vpic
->
ref_flags
.
bits
.
ref_last_sign_bias
=
1
;
vpic
->
refresh_frame_flags
=
0x01
;
}
break
;
case
PICTURE_TYPE_B
:
av_assert0
(
pic
->
nb_refs
==
2
);
if
(
priv
->
last_ref_dir
)
{
{
VAAPIEncodeVP9Picture
*
href0
=
pic
->
refs
[
0
]
->
priv_data
,
*
href1
=
pic
->
refs
[
1
]
->
priv_data
;
av_assert0
(
href0
->
slot
<
pic
->
b_depth
+
1
&&
href1
->
slot
<
pic
->
b_depth
+
1
);
if
(
pic
->
b_depth
==
ctx
->
max_b_depth
)
{
// Unreferenced frame.
vpic
->
refresh_frame_flags
=
0x00
;
hpic
->
slot
=
8
;
}
else
{
vpic
->
refresh_frame_flags
=
0xfe
<<
pic
->
b_depth
&
0xff
;
hpic
->
slot
=
1
+
pic
->
b_depth
;
}
vpic
->
ref_flags
.
bits
.
ref_frame_ctrl_l0
=
1
;
vpic
->
ref_flags
.
bits
.
ref_frame_ctrl_l1
=
2
;
vpic
->
ref_flags
.
bits
.
ref_last_idx
=
0
;
vpic
->
ref_flags
.
bits
.
ref_last_idx
=
href0
->
slot
;
vpic
->
ref_flags
.
bits
.
ref_last_sign_bias
=
1
;
vpic
->
ref_flags
.
bits
.
ref_gf_idx
=
1
;
vpic
->
ref_flags
.
bits
.
ref_gf_idx
=
href1
->
slot
;
vpic
->
ref_flags
.
bits
.
ref_gf_sign_bias
=
0
;
}
else
{
vpic
->
ref_flags
.
bits
.
ref_frame_ctrl_l0
=
2
;
vpic
->
ref_flags
.
bits
.
ref_frame_ctrl_l1
=
1
;
vpic
->
ref_flags
.
bits
.
ref_last_idx
=
0
;
vpic
->
ref_flags
.
bits
.
ref_last_sign_bias
=
0
;
vpic
->
ref_flags
.
bits
.
ref_gf_idx
=
1
;
vpic
->
ref_flags
.
bits
.
ref_gf_sign_bias
=
1
;
}
vpic
->
refresh_frame_flags
=
0x00
;
break
;
default:
av_assert0
(
0
&&
"invalid picture type"
);
}
if
(
vpic
->
refresh_frame_flags
==
0x00
)
{
av_log
(
avctx
,
AV_LOG_DEBUG
,
"Pic %"
PRId64
" not stored.
\n
"
,
pic
->
display_order
);
}
else
{
av_log
(
avctx
,
AV_LOG_DEBUG
,
"Pic %"
PRId64
" stored in slot %d.
\n
"
,
pic
->
display_order
,
hpic
->
slot
);
}
for
(
i
=
0
;
i
<
FF_ARRAY_ELEMS
(
vpic
->
reference_frames
);
i
++
)
vpic
->
reference_frames
[
i
]
=
VA_INVALID_SURFACE
;
if
(
pic
->
type
==
PICTURE_TYPE_P
)
{
av_assert0
(
pic
->
refs
[
0
]);
vpic
->
reference_frames
[
priv
->
last_ref_dir
]
=
pic
->
refs
[
0
]
->
recon_surface
;
}
else
if
(
pic
->
type
==
PICTURE_TYPE_B
)
{
av_assert0
(
pic
->
refs
[
0
]
&&
pic
->
refs
[
1
]);
vpic
->
reference_frames
[
!
priv
->
last_ref_dir
]
=
pic
->
refs
[
0
]
->
recon_surface
;
vpic
->
reference_frames
[
priv
->
last_ref_dir
]
=
pic
->
refs
[
1
]
->
recon_surface
;
for
(
i
=
0
;
i
<
pic
->
nb_refs
;
i
++
)
{
VAAPIEncodePicture
*
ref_pic
=
pic
->
refs
[
i
];
int
slot
;
slot
=
((
VAAPIEncodeVP9Picture
*
)
ref_pic
->
priv_data
)
->
slot
;
av_assert0
(
vpic
->
reference_frames
[
slot
]
==
VA_INVALID_SURFACE
);
vpic
->
reference_frames
[
slot
]
=
ref_pic
->
recon_surface
;
}
vpic
->
pic_flags
.
bits
.
frame_type
=
(
pic
->
type
!=
PICTURE_TYPE_IDR
);
...
...
@@ -175,9 +173,6 @@ static int vaapi_encode_vp9_init_picture_params(AVCodecContext *avctx,
vpic
->
filter_level
=
priv
->
loop_filter_level
;
vpic
->
sharpness_level
=
priv
->
loop_filter_sharpness
;
if
(
ctx
->
b_per_p
>
0
&&
pic
->
type
==
PICTURE_TYPE_P
)
priv
->
last_ref_dir
=
!
priv
->
last_ref_dir
;
return
0
;
}
...
...
@@ -213,7 +208,10 @@ static const VAAPIEncodeProfile vaapi_encode_vp9_profiles[] = {
static
const
VAAPIEncodeType
vaapi_encode_type_vp9
=
{
.
profiles
=
vaapi_encode_vp9_profiles
,
.
flags
=
FLAG_B_PICTURES
,
.
flags
=
FLAG_B_PICTURES
|
FLAG_B_PICTURE_REFERENCES
,
.
picture_priv_data_size
=
sizeof
(
VAAPIEncodeVP9Picture
),
.
configure
=
&
vaapi_encode_vp9_configure
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录