vaapih265dec: fixed st_rps_bits setting in h265 decoding.
authorGuYanjie <yanjie.gu@intel.com>
Tue, 8 Mar 2022 06:54:34 +0000 (14:54 +0800)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Wed, 9 Mar 2022 10:38:36 +0000 (10:38 +0000)
According to va_dec_hevc.h, pic_param->st_rps_bits should be set
for accelorater to skip parsing the *short_term_ref_pic_set
(num_short_term_ref_pic_sets) structure.
Also modified fill_picture to get parser info as a parameter,
in order to get slide_hdr->short_term_ref_pic_set_size.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1886>

subprojects/gstreamer-vaapi/gst-libs/gst/vaapi/gstvaapidecoder_h265.c

index 218a25b..c8cad23 100644 (file)
@@ -1889,10 +1889,12 @@ get_index_for_RefPicListX (VAPictureHEVC * ReferenceFrames,
 }
 
 static gboolean
-fill_picture (GstVaapiDecoderH265 * decoder, GstVaapiPictureH265 * picture)
+fill_picture (GstVaapiDecoderH265 * decoder, GstVaapiPictureH265 * picture,
+    GstVaapiParserInfoH265 * pi)
 {
   GstVaapiDecoderH265Private *const priv = &decoder->priv;
   GstVaapiPicture *const base_picture = &picture->base;
+  GstH265SliceHdr *const slice_hdr = &pi->data.slice_hdr;
   GstH265PPS *const pps = get_pps (decoder);
   GstH265SPS *const sps = get_sps (decoder);
   VAPictureParameterBufferHEVC *pic_param = base_picture->param;
@@ -2034,8 +2036,10 @@ fill_picture (GstVaapiDecoderH265 * decoder, GstVaapiPictureH265 * picture)
   pic_param->pps_tc_offset_div2 = pps->tc_offset_div2;
   COPY_FIELD (pps, num_extra_slice_header_bits);
 
-  /* FIXME: Set correct value as mentioned in va_dec_hevc.h */
-  pic_param->st_rps_bits = 0;
+  if (slice_hdr->short_term_ref_pic_set_sps_flag == 0)
+    pic_param->st_rps_bits = slice_hdr->short_term_ref_pic_set_size;
+  else
+    pic_param->st_rps_bits = 0;
 
 #if VA_CHECK_VERSION(1,2,0)
   if (pic_rext_param) {
@@ -2497,7 +2501,7 @@ decode_picture (GstVaapiDecoderH265 * decoder, GstVaapiDecoderUnit * unit)
   if (!dpb_init (decoder, picture, pi))
     return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;
 
-  if (!fill_picture (decoder, picture))
+  if (!fill_picture (decoder, picture, pi))
     return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;
 
   priv->decoder_state = pi->state;