From 53a0e78948bb43b2d7e21130de14744b0272b126 Mon Sep 17 00:00:00 2001 From: Sreerenj Balachandran Date: Thu, 13 Aug 2015 05:07:52 +0300 Subject: [PATCH] decoder: hevc: Add calculation of WpOffsetHalfRangeC This is necessary for finding ChromaOffsetL0/ChromaOffsetL1 prediction weight table values with out using any hard coding. Fixme: We don't have parser API for sps_range_extension, so assumed zero value for high_precision_offsets_enabled_flag. Signed-off-by: Sreerenj Balachandran --- gst-libs/gst/vaapi/gstvaapidecoder_h265.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_h265.c b/gst-libs/gst/vaapi/gstvaapidecoder_h265.c index eec156c..9b212ad 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_h265.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_h265.c @@ -388,6 +388,7 @@ struct _GstVaapiDecoderH265Private guint RefPicList1_count; guint32 SpsMaxLatencyPictures; + gint32 WpOffsetHalfRangeC; guint nal_length_size; @@ -1487,6 +1488,7 @@ decode_sps (GstVaapiDecoderH265 * decoder, GstVaapiDecoderUnit * unit) GstVaapiDecoderH265Private *const priv = &decoder->priv; GstVaapiParserInfoH265 *const pi = unit->parsed_info; GstH265SPS *const sps = &pi->data.sps; + guint high_precision_offsets_enabled_flag = 0, bitdepthC = 0; GST_DEBUG ("decode SPS"); @@ -1495,6 +1497,13 @@ decode_sps (GstVaapiDecoderH265 * decoder, GstVaapiDecoderUnit * unit) sps->max_num_reorder_pics[sps->max_sub_layers_minus1] + sps->max_latency_increase_plus1[sps->max_sub_layers_minus1] - 1; + /* Calculate WpOffsetHalfRangeC: (7-34) + * Fixme: We don't have parser API for sps_range_extension, so assuming + * high_precision_offsets_enabled_flag as zero */ + bitdepthC = sps->bit_depth_chroma_minus8 + 8; + priv->WpOffsetHalfRangeC = + 1 << (high_precision_offsets_enabled_flag ? (bitdepthC - 1) : 7); + gst_vaapi_parser_info_h265_replace (&priv->sps[sps->id], pi); return GST_VAAPI_DECODER_STATUS_SUCCESS; @@ -2325,6 +2334,7 @@ static gboolean fill_pred_weight_table (GstVaapiDecoderH265 * decoder, GstVaapiSlice * slice, GstH265SliceHdr * slice_hdr) { + GstVaapiDecoderH265Private *const priv = &decoder->priv; VASliceParameterBufferHEVC *const slice_param = slice->param; GstH265PPS *const pps = get_pps (decoder); GstH265SPS *const sps = get_sps (decoder); @@ -2379,9 +2389,10 @@ fill_pred_weight_table (GstVaapiDecoderH265 * decoder, (1 << chroma_log2_weight_denom) + w->delta_chroma_weight_l0[i][j]; /* 7-56 */ slice_param->ChromaOffsetL0[i][j] = CLAMP ( - (127 + w->delta_chroma_offset_l0[i][j] - - ((128 * chroma_weight) >> chroma_log2_weight_denom)), -128, - 127); + (priv->WpOffsetHalfRangeC + w->delta_chroma_offset_l0[i][j] - + ((priv->WpOffsetHalfRangeC * + chroma_weight) >> chroma_log2_weight_denom)), + -priv->WpOffsetHalfRangeC, priv->WpOffsetHalfRangeC - 1); } } } @@ -2400,10 +2411,13 @@ fill_pred_weight_table (GstVaapiDecoderH265 * decoder, chroma_weight = (1 << chroma_log2_weight_denom) + w->delta_chroma_weight_l1[i][j]; + /* 7-56 */ slice_param->ChromaOffsetL1[i][j] = - CLAMP ((127 + w->delta_chroma_offset_l1[i][j] - - ((128 * chroma_weight) >> chroma_log2_weight_denom)), -128, - 127); + CLAMP ((priv->WpOffsetHalfRangeC + + w->delta_chroma_offset_l1[i][j] - + ((priv->WpOffsetHalfRangeC * + chroma_weight) >> chroma_log2_weight_denom)), + -priv->WpOffsetHalfRangeC, priv->WpOffsetHalfRangeC - 1); } } } -- 2.7.4