[Mesa-dev] [PATCH 1/5] st/omx/dec/h265: add scaling list data
Leo Liu
leo.liu at amd.com
Fri Sep 23 16:32:53 UTC 2016
Specified by 7.3.4
Signed-off-by: Leo Liu <leo.liu at amd.com>
---
src/gallium/state_trackers/omx/vid_dec_h265.c | 126 +++++++++++++++++++++++++-
1 file changed, 121 insertions(+), 5 deletions(-)
diff --git a/src/gallium/state_trackers/omx/vid_dec_h265.c b/src/gallium/state_trackers/omx/vid_dec_h265.c
index 0772b4d..3c46505 100644
--- a/src/gallium/state_trackers/omx/vid_dec_h265.c
+++ b/src/gallium/state_trackers/omx/vid_dec_h265.c
@@ -57,6 +57,28 @@ enum {
NAL_UNIT_TYPE_PPS = 34,
};
+static const uint8_t Default_8x8_Intra[64] = {
+ 16, 16, 16, 16, 17, 18, 21, 24,
+ 16, 16, 16, 16, 17, 19, 22, 25,
+ 16, 16, 17, 18, 20, 22, 25, 29,
+ 16, 16, 18, 21, 24, 27, 31, 36,
+ 17, 17, 20, 24, 30, 35, 41, 47,
+ 18, 19, 22, 27, 35, 44, 54, 65,
+ 21, 22, 25, 31, 41, 54, 70, 88,
+ 24, 25, 29, 36, 47, 65, 88, 115
+};
+
+static const uint8_t Default_8x8_Inter[64] = {
+ 16, 16, 16, 16, 17, 18, 20, 24,
+ 16, 16, 16, 17, 18, 20, 24, 25,
+ 16, 16, 17, 18, 20, 24, 25, 28,
+ 16, 17, 18, 20, 24, 25, 28, 33,
+ 17, 18, 20, 24, 25, 28, 33, 41,
+ 18, 20, 24, 25, 28, 33, 41, 54,
+ 20, 24, 25, 28, 33, 41, 54, 71,
+ 24, 25, 28, 33, 41, 54, 71, 91
+};
+
struct dpb_list {
struct list_head list;
struct pipe_video_buffer *buffer;
@@ -188,10 +210,104 @@ static unsigned profile_tier_level(struct vl_rbsp *rbsp,
return level_idc;
}
-static void scaling_list_data(void)
+static void scaling_list_data(vid_dec_PrivateType *priv,
+ struct vl_rbsp *rbsp, struct pipe_h265_sps *sps)
{
- /* TODO */
- assert(0);
+ unsigned size_id, matrix_id;
+
+ for (size_id = 0; size_id < 4; ++size_id) {
+ for (matrix_id = 0; matrix_id < ((size_id == 3) ? 2 : 6); ++matrix_id) {
+ bool scaling_list_pred_mode_flag = vl_rbsp_u(rbsp, 1);
+
+ if (!scaling_list_pred_mode_flag) {
+ unsigned scaling_list_pred_matrix_id_delta = vl_rbsp_ue(rbsp);
+ unsigned matrix_id_with_delta = matrix_id -
+ scaling_list_pred_matrix_id_delta;
+
+ if (matrix_id != matrix_id_with_delta) {
+ switch (size_id) {
+ case 0:
+ memcpy(sps->ScalingList4x4[matrix_id],
+ sps->ScalingList4x4[matrix_id_with_delta], 16);
+ break;
+ case 1:
+ memcpy(sps->ScalingList8x8[matrix_id],
+ sps->ScalingList8x8[matrix_id_with_delta], 64);
+ break;
+ case 2:
+ memcpy(sps->ScalingList16x16[matrix_id],
+ sps->ScalingList16x16[matrix_id_with_delta], 64);
+ sps->ScalingListDCCoeff16x16[matrix_id] =
+ sps->ScalingListDCCoeff16x16[matrix_id_with_delta];
+ break;
+ case 3:
+ memcpy(sps->ScalingList32x32[matrix_id],
+ sps->ScalingList32x32[matrix_id_with_delta], 64);
+ sps->ScalingListDCCoeff32x32[matrix_id] =
+ sps->ScalingListDCCoeff32x32[matrix_id_with_delta];
+ break;
+ }
+ } else {
+ const uint8_t *d;
+
+ switch (size_id) {
+ case 0:
+ memset(sps->ScalingList4x4[matrix_id], 16, 16);
+ break;
+ case 1:
+ d = (matrix_id < 3) ? Default_8x8_Intra : Default_8x8_Inter;
+ memcpy(sps->ScalingList8x8[matrix_id], d, 64);
+ break;
+ case 2:
+ d = (matrix_id < 3) ? Default_8x8_Intra : Default_8x8_Inter;
+ memcpy(sps->ScalingList16x16[matrix_id], d, 64);
+ sps->ScalingListDCCoeff16x16[matrix_id] = 16;
+ break;
+ case 3:
+ d = (matrix_id < 1) ? Default_8x8_Intra : Default_8x8_Inter;
+ memcpy(sps->ScalingList32x32[matrix_id], d, 64);
+ sps->ScalingListDCCoeff32x32[matrix_id] = 16;
+ break;
+ }
+ }
+ } else {
+ int next_coef = 8;
+ int coef_num = MIN2(64, (1 << (4 + (size_id << 1))));
+ int i;
+
+ if (size_id > 1) {
+ int scaling_list_dc_coef_minus8 = vl_rbsp_se(rbsp);
+
+ next_coef = scaling_list_dc_coef_minus8 + 8;
+ if (size_id == 2)
+ sps->ScalingListDCCoeff16x16[matrix_id] = next_coef;
+ else
+ sps->ScalingListDCCoeff32x32[matrix_id] = next_coef;
+ }
+ for (i = 0; i < coef_num; ++i) {
+ int scaling_list_delta_coef = vl_rbsp_se(rbsp);
+
+ next_coef = (next_coef + scaling_list_delta_coef + 256) % 256;
+ switch (size_id) {
+ case 0:
+ sps->ScalingList4x4[matrix_id][i] = next_coef;
+ break;
+ case 1:
+ sps->ScalingList8x8[matrix_id][i] = next_coef;
+ break;
+ case 2:
+ sps->ScalingList16x16[matrix_id][i] = next_coef;
+ break;
+ case 3:
+ sps->ScalingList32x32[matrix_id][i] = next_coef;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return;
}
static void st_ref_pic_set(vid_dec_PrivateType *priv, struct vl_rbsp *rbsp,
@@ -383,7 +499,7 @@ static void seq_parameter_set(vid_dec_PrivateType *priv, struct vl_rbsp *rbsp)
if (sps->scaling_list_enabled_flag)
/* sps_scaling_list_data_present_flag */
if (vl_rbsp_u(rbsp, 1))
- scaling_list_data();
+ scaling_list_data(priv, rbsp, sps);
sps->amp_enabled_flag = vl_rbsp_u(rbsp, 1);
sps->sample_adaptive_offset_enabled_flag = vl_rbsp_u(rbsp, 1);
@@ -506,7 +622,7 @@ static void picture_parameter_set(vid_dec_PrivateType *priv,
/* pps_scaling_list_data_present_flag */
if (vl_rbsp_u(rbsp, 1))
- scaling_list_data();
+ scaling_list_data(priv, rbsp, sps);
pps->lists_modification_present_flag = vl_rbsp_u(rbsp, 1);
pps->log2_parallel_merge_level_minus2 = vl_rbsp_ue(rbsp);
--
2.7.4
More information about the mesa-dev
mailing list