From 6f2ab31d10d0d4181026eafced3568fe39452b4c Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Fri, 20 Sep 2019 20:14:57 +0900 Subject: [PATCH] h265parser: Calculate short term RPS size in slice header The calculated size of short_term_ref_pic_set is not a part of HEVC syntax but the value is used by some stateless decoders (e.g., vaapi, dxva, vdpau and nvdec) for the purpose of skipping parsing the syntax by the accelerator. --- gst-libs/gst/codecparsers/gsth265parser.c | 3 +++ gst-libs/gst/codecparsers/gsth265parser.h | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/gst-libs/gst/codecparsers/gsth265parser.c b/gst-libs/gst/codecparsers/gsth265parser.c index 0cb003807a..d4ad4c21ce 100644 --- a/gst-libs/gst/codecparsers/gsth265parser.c +++ b/gst-libs/gst/codecparsers/gsth265parser.c @@ -2271,10 +2271,13 @@ gst_h265_parser_parse_slice_hdr (GstH265Parser * parser, READ_UINT8 (&nr, slice->short_term_ref_pic_set_sps_flag, 1); if (!slice->short_term_ref_pic_set_sps_flag) { + guint pos = nal_reader_get_pos (&nr); if (!gst_h265_parser_parse_short_term_ref_pic_sets (&slice->short_term_ref_pic_sets, &nr, sps->num_short_term_ref_pic_sets, sps)) goto error; + + slice->short_term_ref_pic_set_size = nal_reader_get_pos (&nr) - pos; } else if (sps->num_short_term_ref_pic_sets > 1) { const guint n = ceil_log2 (sps->num_short_term_ref_pic_sets); READ_UINT8 (&nr, slice->short_term_ref_pic_set_idx, n); diff --git a/gst-libs/gst/codecparsers/gsth265parser.h b/gst-libs/gst/codecparsers/gsth265parser.h index 30ad695d37..619683adde 100644 --- a/gst-libs/gst/codecparsers/gsth265parser.h +++ b/gst-libs/gst/codecparsers/gsth265parser.h @@ -1189,6 +1189,8 @@ struct _GstH265PredWeightTable * @header_size: the calculated size of the slice_header() in bits. * @n_emulation_prevention_bytes: number of emulation prevention bytes (EPB) * in this slice_header() + * @short_term_ref_pic_set_size: the calculated size of short_term_ref_pic_set() + * in bits. (Since: 1.18) */ struct _GstH265SliceHdr { @@ -1260,6 +1262,9 @@ struct _GstH265SliceHdr guint header_size; /* Number of emulation prevention bytes (EPB) in this slice_header() */ guint n_emulation_prevention_bytes; + + /* Size of short_term_ref_pic_set() in bits */ + guint short_term_ref_pic_set_size; }; struct _GstH265PicTiming