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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1930>
This commit is contained in:
Seungha Yang 2022-03-11 20:46:11 +09:00 committed by GStreamer Marge Bot
parent bd5d24822a
commit d4f9676c9c
2 changed files with 7 additions and 2 deletions

View file

@ -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);

View file

@ -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;
};