codecs: GstMpeg2Slice: add field for sc_offset and size
authorDaniel Almeida <daniel.almeida@collabora.com>
Fri, 26 Mar 2021 18:31:51 +0000 (15:31 -0300)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 2 Nov 2021 16:16:29 +0000 (16:16 +0000)
Downstream might need the start code offset when decoding.

Previously this computation would be scattered in multiple sites. This
is error prone, so move it to the base class. Subclasses can access
slice->sc_offset directly without computing the address themselves
knowing that the size will also take the start code into account.

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

subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstmpeg2decoder.c
subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstmpeg2picture.h

index 3121f341ee6e8131eede2c55b063ce1436efb1b3..8bd4550bc1859dd6283517bc9515924c3372544c 100644 (file)
@@ -949,6 +949,8 @@ gst_mpeg2_decoder_handle_slice (GstMpeg2Decoder * decoder,
   slice.pic_hdr = &priv->pic_hdr;
   slice.pic_ext = _pic_hdr_ext_is_valid (&priv->pic_ext) ?
       &priv->pic_ext : NULL;
+  slice.sc_offset = slice.packet.offset - 4;
+  slice.size = slice.packet.size + 4;
 
   ret = gst_mpeg2_decoder_ensure_current_picture (decoder, &slice);
   if (ret != GST_FLOW_OK) {
index 7262c967168d30c66c7756e4d6f2ba107c28ac74..77244a5e52356687790950b2dec2b484fdf2cb58 100644 (file)
@@ -65,6 +65,10 @@ struct _GstMpeg2Slice
 
   /* parsed video packet (doesn't take ownership of raw data) */
   GstMpegVideoPacket packet;
+  /* offset of the start code for the slice */
+  guint sc_offset;
+  /* size, including the start code */
+  guint size;
 };
 
 /**