codecs: GstMpeg2Slice: add field for sc_offset and size

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>
This commit is contained in:
Daniel Almeida 2021-03-26 15:31:51 -03:00 committed by GStreamer Marge Bot
parent 8b932c105f
commit 946be1a85a
2 changed files with 6 additions and 0 deletions

View 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) {

View 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;
};
/**