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
/
0030-lavc-vaapi_hevc-fill-rext-luma-chroma-offset-in-the-.patch
107 lines (96 loc) · 5.23 KB
/
0030-lavc-vaapi_hevc-fill-rext-luma-chroma-offset-in-the-.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
99
100
101
102
103
104
105
106
From 8fe75707f3142220f02720b88144f50a044c4362 Mon Sep 17 00:00:00 2001
From: Xu Guangxin <[email protected]>
Date: Thu, 12 Mar 2020 12:04:53 -0400
Subject: [PATCH] lavc/vaapi_hevc: fill rext luma/chroma offset in the right
way
For range extension, the luma/chroma offset is larger than 8 bits, we need fill the 16 bits version
---
libavcodec/vaapi_hevc.c | 48 +++++++++++++++++++++++++++--------------
1 file changed, 32 insertions(+), 16 deletions(-)
diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index d832b8cb0d..e1c4f26741 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -322,10 +322,17 @@ fail:
return ret;
}
-static void fill_pred_weight_table(const HEVCContext *h,
+static void fill_pred_weight_table(const AVCodecContext *avctx,
+ const HEVCContext *h,
const SliceHeader *sh,
VASliceParameterBufferHEVC *slice_param)
{
+#if VA_CHECK_VERSION(1, 2, 0)
+ int is_rext = avctx->profile == FF_PROFILE_HEVC_REXT;
+#else
+ int is_rext = 0;
+#endif
+
int i;
memset(slice_param->delta_luma_weight_l0, 0, sizeof(slice_param->delta_luma_weight_l0));
@@ -353,21 +360,26 @@ static void fill_pred_weight_table(const HEVCContext *h,
for (i = 0; i < 15 && i < sh->nb_refs[L0]; i++) {
slice_param->delta_luma_weight_l0[i] = sh->luma_weight_l0[i] - (1 << sh->luma_log2_weight_denom);
- slice_param->luma_offset_l0[i] = sh->luma_offset_l0[i];
+
slice_param->delta_chroma_weight_l0[i][0] = sh->chroma_weight_l0[i][0] - (1 << sh->chroma_log2_weight_denom);
slice_param->delta_chroma_weight_l0[i][1] = sh->chroma_weight_l0[i][1] - (1 << sh->chroma_log2_weight_denom);
- slice_param->ChromaOffsetL0[i][0] = sh->chroma_offset_l0[i][0];
- slice_param->ChromaOffsetL0[i][1] = sh->chroma_offset_l0[i][1];
+ if (!is_rext) {
+ slice_param->luma_offset_l0[i] = sh->luma_offset_l0[i];
+ slice_param->ChromaOffsetL0[i][0] = sh->chroma_offset_l0[i][0];
+ slice_param->ChromaOffsetL0[i][1] = sh->chroma_offset_l0[i][1];
+ }
}
if (sh->slice_type == HEVC_SLICE_B) {
for (i = 0; i < 15 && i < sh->nb_refs[L1]; i++) {
slice_param->delta_luma_weight_l1[i] = sh->luma_weight_l1[i] - (1 << sh->luma_log2_weight_denom);
- slice_param->luma_offset_l1[i] = sh->luma_offset_l1[i];
slice_param->delta_chroma_weight_l1[i][0] = sh->chroma_weight_l1[i][0] - (1 << sh->chroma_log2_weight_denom);
slice_param->delta_chroma_weight_l1[i][1] = sh->chroma_weight_l1[i][1] - (1 << sh->chroma_log2_weight_denom);
- slice_param->ChromaOffsetL1[i][0] = sh->chroma_offset_l1[i][0];
- slice_param->ChromaOffsetL1[i][1] = sh->chroma_offset_l1[i][1];
+ if (!is_rext) {
+ slice_param->luma_offset_l1[i] = sh->luma_offset_l1[i];
+ slice_param->ChromaOffsetL1[i][0] = sh->chroma_offset_l1[i][0];
+ slice_param->ChromaOffsetL1[i][1] = sh->chroma_offset_l1[i][1];
+ }
}
}
}
@@ -462,7 +474,7 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
last_slice_param->RefPicList[list_idx][i] = get_ref_pic_index(h, rpl->ref[i]);
}
- fill_pred_weight_table(h, sh, last_slice_param);
+ fill_pred_weight_table(avctx, h, sh, last_slice_param);
#if VA_CHECK_VERSION(1, 2, 0)
if (avctx->profile == FF_PROFILE_HEVC_REXT) {
@@ -471,15 +483,19 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
.cu_chroma_qp_offset_enabled_flag = sh->cu_chroma_qp_offset_enabled_flag,
},
};
+ 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];
+ pic->last_slice_param.rext.ChromaOffsetL0[i][0] = sh->chroma_offset_l0[i][0];
+ pic->last_slice_param.rext.ChromaOffsetL0[i][1] = sh->chroma_offset_l0[i][1];
+ }
- memcpy(pic->last_slice_param.rext.luma_offset_l0, pic->last_slice_param.base.luma_offset_l0,
- sizeof(pic->last_slice_param.base.luma_offset_l0));
- memcpy(pic->last_slice_param.rext.luma_offset_l1, pic->last_slice_param.base.luma_offset_l1,
- sizeof(pic->last_slice_param.base.luma_offset_l1));
- memcpy(pic->last_slice_param.rext.ChromaOffsetL0, pic->last_slice_param.base.ChromaOffsetL0,
- sizeof(pic->last_slice_param.base.ChromaOffsetL0));
- memcpy(pic->last_slice_param.rext.ChromaOffsetL1, pic->last_slice_param.base.ChromaOffsetL1,
- sizeof(pic->last_slice_param.base.ChromaOffsetL1));
+ if (sh->slice_type == HEVC_SLICE_B) {
+ for (i = 0; i < 15 && i < sh->nb_refs[L1]; i++) {
+ pic->last_slice_param.rext.luma_offset_l1[i] = sh->luma_offset_l1[i];
+ pic->last_slice_param.rext.ChromaOffsetL1[i][0] = sh->chroma_offset_l1[i][0];
+ pic->last_slice_param.rext.ChromaOffsetL1[i][1] = sh->chroma_offset_l1[i][1];
+ }
+ }
}
#endif
--
2.17.1