codecparsers: h265: Introduce long_term_ref_pic_set_size
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Fri, 29 Apr 2022 16:10:05 +0000 (12:10 -0400)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Fri, 22 Jul 2022 14:21:02 +0000 (10:21 -0400)
This is the size of the `if( long_term_ref_pics_present_flag )` inside
slice_segment_header( ) syntax. This size in bit, and after de-emulation
is needed by some HW.

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

subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.c
subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.h

index 95bf642b9877f7cc62ba06acbf89bdf987062759..81f7ec201742ce4bd500ac974daa20de59a57dbe 100644 (file)
@@ -2672,7 +2672,6 @@ gst_h265_parser_parse_slice_hdr (GstH265Parser * parser,
       nal_reader_skip (&nr, 1);
     READ_UE_MAX (&nr, slice->type, 63);
 
-
     if (pps->output_flag_present_flag)
       READ_UINT8 (&nr, slice->pic_output_flag, 1);
     if (sps->separate_colour_plane_flag == 1)
@@ -2704,6 +2703,8 @@ gst_h265_parser_parse_slice_hdr (GstH265Parser * parser,
 
       if (sps->long_term_ref_pics_present_flag) {
         guint32 limit;
+        guint pos = nal_reader_get_pos (&nr);
+        guint epb_pos = nal_reader_get_epb_count (&nr);
 
         if (sps->num_long_term_ref_pics_sps > 0)
           READ_UE_MAX (&nr, slice->num_long_term_sps,
@@ -2733,6 +2734,10 @@ gst_h265_parser_parse_slice_hdr (GstH265Parser * parser,
           if (slice->delta_poc_msb_present_flag[i])
             READ_UE (&nr, slice->delta_poc_msb_cycle_lt[i]);
         }
+
+        slice->long_term_ref_pic_set_size =
+            (nal_reader_get_pos (&nr) - pos) -
+            (8 * (nal_reader_get_epb_count (&nr) - epb_pos));
       }
       if (sps->temporal_mvp_enabled_flag)
         READ_UINT8 (&nr, slice->temporal_mvp_enabled_flag, 1);
index ca2e91bb405ca53c3560c0d584ce6ad1767cacec..304246704fa5ca8ea68b536e94fccd51cb3b7805 100644 (file)
@@ -1384,6 +1384,9 @@ struct _GstH265PredWeightTable
  *   in this slice_header\()
  * @short_term_ref_pic_set_size: the calculated size of short_term_ref_pic_set\()
  *   in bits. (Since: 1.18)
+ * @long_term_ref_pic_set_size: the calculated size of the branch
+ *   `if( long_term_ref_pics_present_flag )` `inside slice_segment_header()` syntax
+ *   in bits. (Since: 1.22)
  */
 struct _GstH265SliceHdr
 {
@@ -1463,6 +1466,16 @@ struct _GstH265SliceHdr
   /* Size of short_term_ref_pic_set() after emulation preventation bytes are
    * removed, in bits */
   guint short_term_ref_pic_set_size;
+
+  /**
+   * _GstH265SliceHdr.long_term_ref_pic_set_size:
+   *
+   * The calculated size of the branch `if( long_term_ref_pics_present_flag )`
+   * inside `slice_segment_header()` syntax in bits.
+   *
+   * Since: 1.22
+   */
+  guint long_term_ref_pic_set_size;
 };
 
 struct _GstH265PicTiming