From: Seungha Yang Date: Fri, 11 Mar 2022 11:46:11 +0000 (+0900) Subject: h265parser: Fix short_term_ref_pic_set() size calculation X-Git-Tag: 1.22.0~1906 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d4f9676c9c8a74f1e13bf5e175a3d30b0ee097b3;p=platform%2Fupstream%2Fgstreamer.git h265parser: Fix short_term_ref_pic_set() size calculation This field is used by DXVA/NVDEC/VA, and each specification describes (NVDEC is not well documented) that it's the number of bits used in short_term_ref_pic_set(). DXVA doesn't explicitly mention that whether the size of emulation preventation bytes (EPB) is inclusive or not, but VA is clearly specifying that it's the size after removing EPB. Excluding EPB size here makes more sense therefore. Part-of: --- diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.c b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.c index 74fc25c..bcc4d84 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.c @@ -2512,12 +2512,16 @@ 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); + guint epb_pos = nal_reader_get_epb_count (&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; + slice->short_term_ref_pic_set_size = + (nal_reader_get_pos (&nr) - pos) - + (8 * (nal_reader_get_epb_count (&nr) - epb_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/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.h b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.h index 0d80c19..ba94ac7 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.h @@ -1460,7 +1460,8 @@ struct _GstH265SliceHdr /* Number of emulation prevention bytes (EPB) in this slice_header() */ guint n_emulation_prevention_bytes; - /* Size of short_term_ref_pic_set() in bits */ + /* Size of short_term_ref_pic_set() after emulation preventation bytes are + * removed, in bits */ guint short_term_ref_pic_set_size; };