This repository has been archived by the owner on Feb 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
0072-lavc-vaapi_hevc-Pass-SCC-parameters-Through-VA-API.patch
99 lines (86 loc) · 5.06 KB
/
0072-lavc-vaapi_hevc-Pass-SCC-parameters-Through-VA-API.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
From 311110a8014045616b961e2a18e313770146c423 Mon Sep 17 00:00:00 2001
From: Linjie Fu <[email protected]>
Date: Fri, 5 Jun 2020 13:36:41 +0800
Subject: [PATCH 08/15] lavc/vaapi_hevc: Pass SCC parameters Through VA-API
Including sps/pps/slice parameters.
Signed-off-by: Linjie Fu <[email protected]>
---
libavcodec/vaapi_hevc.c | 40 +++++++++++++++++++++++++++++++++++-----
1 file changed, 35 insertions(+), 5 deletions(-)
diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 7d68861c1e..4e3ae6cf3b 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -124,7 +124,7 @@ static int vaapi_hevc_start_frame(AVCodecContext *avctx,
const HEVCPPS *pps = h->ps.pps;
const ScalingList *scaling_list = NULL;
- int pic_param_size, err, i;
+ int pic_param_size, num_comps, err, i;
VAPictureParameterBufferHEVC *pic_param = (VAPictureParameterBufferHEVC *)&pic->pic_param;
@@ -245,8 +245,35 @@ static int vaapi_hevc_start_frame(AVCodecContext *avctx,
for (i = 0; i < 6; i++)
pic->pic_param.rext.cr_qp_offset_list[i] = pps->cr_qp_offset_list[i];
}
+
+ if (avctx->profile == FF_PROFILE_HEVC_SCC) {
+ pic->pic_param.scc = (VAPictureParameterBufferHEVCScc) {
+ .screen_content_pic_fields.bits = {
+ .pps_curr_pic_ref_enabled_flag = pps->pps_curr_pic_ref_enabled_flag,
+ .palette_mode_enabled_flag = sps->palette_mode_enabled_flag,
+ .motion_vector_resolution_control_idc = sps->motion_vector_resolution_control_idc,
+ .intra_boundary_filtering_disabled_flag = sps->intra_boundary_filtering_disabled_flag,
+ .residual_adaptive_colour_transform_enabled_flag
+ = pps->residual_adaptive_colour_transform_enabled_flag,
+ .pps_slice_act_qp_offsets_present_flag = pps->pps_slice_act_qp_offsets_present_flag,
+ },
+ .palette_max_size = sps->palette_max_size,
+ .delta_palette_max_predictor_size = sps->delta_palette_max_predictor_size,
+ .predictor_palette_size = pps->pps_num_palette_predictor_initializers,
+ .pps_act_y_qp_offset_plus5 = pps->pps_act_y_qp_offset + 5,
+ .pps_act_cb_qp_offset_plus5 = pps->pps_act_cb_qp_offset + 5,
+ .pps_act_cr_qp_offset_plus3 = pps->pps_act_cr_qp_offset + 3,
+ };
+
+ num_comps = pps->monochrome_palette_flag ? 1 : 3;
+ for (int comp = 0; comp < num_comps; comp++)
+ for (i = 0; i < pps->pps_num_palette_predictor_initializers; i++)
+ pic->pic_param.scc.predictor_palette_entries[comp][i]
+ = pps->pps_palette_predictor_initializer[comp][i];
+ }
+
#endif
- pic_param_size = avctx->profile == FF_PROFILE_HEVC_REXT ?
+ pic_param_size = avctx->profile >= FF_PROFILE_HEVC_REXT ?
sizeof(pic->pic_param) : sizeof(VAPictureParameterBufferHEVC);
err = ff_vaapi_decode_make_param_buffer(avctx, &pic->pic,
@@ -299,7 +326,7 @@ static int vaapi_hevc_end_frame(AVCodecContext *avctx)
VASliceParameterBufferHEVC *last_slice_param = (VASliceParameterBufferHEVC *)&pic->last_slice_param;
int ret;
- int slice_param_size = avctx->profile == FF_PROFILE_HEVC_REXT ?
+ int slice_param_size = avctx->profile >= FF_PROFILE_HEVC_REXT ?
sizeof(pic->last_slice_param) : sizeof(VASliceParameterBufferHEVC);
if (pic->last_size) {
@@ -412,7 +439,7 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
VAAPIDecodePictureHEVC *pic = h->ref->hwaccel_picture_private;
VASliceParameterBufferHEVC *last_slice_param = (VASliceParameterBufferHEVC *)&pic->last_slice_param;
- int slice_param_size = avctx->profile == FF_PROFILE_HEVC_REXT ?
+ int slice_param_size = avctx->profile >= FF_PROFILE_HEVC_REXT ?
sizeof(pic->last_slice_param) : sizeof(VASliceParameterBufferHEVC);
int nb_list = (sh->slice_type == HEVC_SLICE_B) ?
@@ -477,11 +504,14 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
fill_pred_weight_table(avctx, h, sh, last_slice_param);
#if VA_CHECK_VERSION(1, 2, 0)
- if (avctx->profile == FF_PROFILE_HEVC_REXT) {
+ if (avctx->profile >= FF_PROFILE_HEVC_REXT) {
pic->last_slice_param.rext = (VASliceParameterBufferHEVCRext) {
.slice_ext_flags.bits = {
.cu_chroma_qp_offset_enabled_flag = sh->cu_chroma_qp_offset_enabled_flag,
},
+ .slice_act_y_qp_offset = sh->slice_act_y_qp_offset,
+ .slice_act_cb_qp_offset = sh->slice_act_cb_qp_offset,
+ .slice_act_cr_qp_offset = sh->slice_act_cr_qp_offset,
};
for (i = 0; i < 15 && i < sh->nb_refs[L0]; i++) {
pic->last_slice_param.rext.luma_offset_l0[i] = sh->luma_offset_l0[i];
--
2.17.1