diff options
author | He Junyan <junyan.he@intel.com> | 2020-12-18 21:25:08 +0800 |
---|---|---|
committer | He Junyan <junyan.he@intel.com> | 2020-12-28 13:05:29 +0800 |
commit | 0e161dd3638b4839cec9429eb7d113a50d7a659d (patch) | |
tree | 3027ef3ce64b38f2a3110818656e215441a469d8 /gst-libs/gst/codecs/gstmpeg2picture.h | |
parent | e82f1f8b0b45d53ed82d30fdccc33fec304d4101 (diff) | |
download | gstreamer-plugins-bad-0e161dd3638b4839cec9429eb7d113a50d7a659d.tar.gz |
codecs: Add mpeg2 stateless decoder base class.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1798>
Diffstat (limited to 'gst-libs/gst/codecs/gstmpeg2picture.h')
-rw-r--r-- | gst-libs/gst/codecs/gstmpeg2picture.h | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/gst-libs/gst/codecs/gstmpeg2picture.h b/gst-libs/gst/codecs/gstmpeg2picture.h new file mode 100644 index 000000000..f3925b4ea --- /dev/null +++ b/gst-libs/gst/codecs/gstmpeg2picture.h @@ -0,0 +1,148 @@ +/* GStreamer + * Copyright (C) 2020 Intel Corporation + * Author: He Junyan <junyan.he@intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_MPEG2_PICTURE_H__ +#define __GST_MPEG2_PICTURE_H__ + +#include <gst/codecs/codecs-prelude.h> +#include <gst/codecparsers/gstmpegvideoparser.h> + +G_BEGIN_DECLS + +#define GST_TYPE_MPEG2_PICTURE (gst_mpeg2_picture_get_type()) +#define GST_IS_MPEG2_PICTURE(obj) (GST_IS_MINI_OBJECT_TYPE(obj, GST_TYPE_MPEG2_PICTURE)) +#define GST_MPEG2_PICTURE(obj) ((GstMpeg2Picture *)obj) +#define GST_MPEG2_PICTURE_CAST(obj) (GST_MPEG2_PICTURE(obj)) + +typedef struct _GstMpeg2Slice GstMpeg2Slice; + +struct _GstMpeg2Slice +{ + /* The parameter set */ + GstMpegVideoQuantMatrixExt *quant_matrix; + GstMpegVideoPictureHdr *pic_hdr; + GstMpegVideoPictureExt *pic_ext; + + GstMpegVideoSliceHdr header; + + /* parsed video packet (doesn't take ownership of raw data) */ + GstMpegVideoPacket packet; +}; + +typedef struct _GstMpeg2Picture GstMpeg2Picture; + +struct _GstMpeg2Picture +{ + /*< private >*/ + GstMiniObject parent; + + /* From GstVideoCodecFrame */ + guint32 system_frame_number; + gboolean needed_for_output; + /* For interlaced streams */ + GstMpeg2Picture *first_field; + + gint pic_order_cnt; + gint tsn; + GstMpegVideoPictureStructure structure; + GstMpegVideoPictureType type; + + gpointer user_data; + GDestroyNotify notify; +}; + +#define GST_MPEG2_PICTURE_IS_REF(picture) \ + (((GstMpeg2Picture *) picture)->type == GST_MPEG_VIDEO_PICTURE_TYPE_I || \ + ((GstMpeg2Picture *) picture)->type == GST_MPEG_VIDEO_PICTURE_TYPE_P) + +GST_CODECS_API +GType gst_mpeg2_picture_get_type (void); + +GST_CODECS_API +GstMpeg2Picture * gst_mpeg2_picture_new (void); + +static inline GstMpeg2Picture * +gst_mpeg2_picture_ref (GstMpeg2Picture * picture) +{ + return (GstMpeg2Picture *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (picture)); +} + +static inline void +gst_mpeg2_picture_unref (GstMpeg2Picture * picture) +{ + gst_mini_object_unref (GST_MINI_OBJECT_CAST (picture)); +} + +static inline gboolean +gst_mpeg2_picture_replace (GstMpeg2Picture ** old_picture, + GstMpeg2Picture * new_picture) +{ + return gst_mini_object_replace ((GstMiniObject **) old_picture, + (GstMiniObject *) new_picture); +} + +static inline void +gst_mpeg2_picture_clear (GstMpeg2Picture ** picture) +{ + if (picture && *picture) { + gst_mpeg2_picture_unref (*picture); + *picture = NULL; + } +} + +GST_CODECS_API +void gst_mpeg2_picture_set_user_data (GstMpeg2Picture * picture, + gpointer user_data, + GDestroyNotify notify); + +GST_CODECS_API +gpointer gst_mpeg2_picture_get_user_data (GstMpeg2Picture * picture); + +typedef struct _GstMpeg2Dpb GstMpeg2Dpb; + +GST_CODECS_API +GstMpeg2Dpb * gst_mpeg2_dpb_new (void); + +GST_CODECS_API +void gst_mpeg2_dpb_free (GstMpeg2Dpb * dpb); + +GST_CODECS_API +void gst_mpeg2_dpb_clear (GstMpeg2Dpb * dpb); + +GST_CODECS_API +void gst_mpeg2_dpb_add (GstMpeg2Dpb * dpb, + GstMpeg2Picture * picture); +GST_CODECS_API +GstMpeg2Picture * gst_mpeg2_dpb_bump (GstMpeg2Dpb * dpb); + +GST_CODECS_API +gboolean gst_mpeg2_dpb_need_bump (GstMpeg2Dpb * dpb); + +GST_CODECS_API +void gst_mpeg2_dpb_get_neighbours (GstMpeg2Dpb * dpb, + GstMpeg2Picture * picture, + GstMpeg2Picture ** prev_picture_ptr, + GstMpeg2Picture ** next_picture_ptr); + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstMpeg2Picture, gst_mpeg2_picture_unref) + +G_END_DECLS + +#endif /* __GST_MPEG2_PICTURE_H__ */ |