2 * Copyright (C) 2020 Intel Corporation
3 * Author: He Junyan <junyan.he@intel.com>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
21 #ifndef __GST_MPEG2_PICTURE_H__
22 #define __GST_MPEG2_PICTURE_H__
24 #include <gst/codecs/codecs-prelude.h>
25 #include <gst/codecparsers/gstmpegvideoparser.h>
26 #include <gst/video/video.h>
31 * GST_TYPE_MPEG2_PICTURE:
35 #define GST_TYPE_MPEG2_PICTURE (gst_mpeg2_picture_get_type())
37 * GST_IS_MPEG2_PICTURE:
41 #define GST_IS_MPEG2_PICTURE(obj) (GST_IS_MINI_OBJECT_TYPE(obj, GST_TYPE_MPEG2_PICTURE))
47 #define GST_MPEG2_PICTURE(obj) ((GstMpeg2Picture *)obj)
49 typedef struct _GstMpeg2Slice GstMpeg2Slice;
50 typedef struct _GstMpeg2Picture GstMpeg2Picture;
60 GstMpegVideoQuantMatrixExt *quant_matrix; /* The parameter set */
61 GstMpegVideoPictureHdr *pic_hdr;
62 GstMpegVideoPictureExt *pic_ext;
64 GstMpegVideoSliceHdr header;
66 /* parsed video packet (doesn't take ownership of raw data) */
67 GstMpegVideoPacket packet;
75 struct _GstMpeg2Picture
80 /* From GstVideoCodecFrame */
81 guint32 system_frame_number;
82 gboolean needed_for_output;
83 /* For interlaced streams */
84 GstMpeg2Picture *first_field;
86 GstVideoBufferFlags buffer_flags;
90 GstMpegVideoPictureStructure structure;
91 GstMpegVideoPictureType type;
94 GDestroyNotify notify;
98 * GST_MPEG2_PICTURE_IS_REF:
99 * @picture: a #GstMpeg2Picture
101 * Check whether @picture's type is I or P
105 #define GST_MPEG2_PICTURE_IS_REF(picture) \
106 (((GstMpeg2Picture *) picture)->type == GST_MPEG_VIDEO_PICTURE_TYPE_I || \
107 ((GstMpeg2Picture *) picture)->type == GST_MPEG_VIDEO_PICTURE_TYPE_P)
110 GType gst_mpeg2_picture_get_type (void);
113 GstMpeg2Picture * gst_mpeg2_picture_new (void);
115 static inline GstMpeg2Picture *
116 gst_mpeg2_picture_ref (GstMpeg2Picture * picture)
118 return (GstMpeg2Picture *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (picture));
122 gst_mpeg2_picture_unref (GstMpeg2Picture * picture)
124 gst_mini_object_unref (GST_MINI_OBJECT_CAST (picture));
127 static inline gboolean
128 gst_mpeg2_picture_replace (GstMpeg2Picture ** old_picture,
129 GstMpeg2Picture * new_picture)
131 return gst_mini_object_replace ((GstMiniObject **) old_picture,
132 (GstMiniObject *) new_picture);
136 gst_mpeg2_picture_clear (GstMpeg2Picture ** picture)
138 if (picture && *picture) {
139 gst_mpeg2_picture_unref (*picture);
145 void gst_mpeg2_picture_set_user_data (GstMpeg2Picture * picture,
147 GDestroyNotify notify);
150 gpointer gst_mpeg2_picture_get_user_data (GstMpeg2Picture * picture);
158 typedef struct _GstMpeg2Dpb GstMpeg2Dpb;
161 GstMpeg2Dpb * gst_mpeg2_dpb_new (void);
164 void gst_mpeg2_dpb_free (GstMpeg2Dpb * dpb);
167 void gst_mpeg2_dpb_clear (GstMpeg2Dpb * dpb);
170 void gst_mpeg2_dpb_add (GstMpeg2Dpb * dpb,
171 GstMpeg2Picture * picture);
173 GstMpeg2Picture * gst_mpeg2_dpb_bump (GstMpeg2Dpb * dpb);
176 gboolean gst_mpeg2_dpb_need_bump (GstMpeg2Dpb * dpb);
179 void gst_mpeg2_dpb_get_neighbours (GstMpeg2Dpb * dpb,
180 GstMpeg2Picture * picture,
181 GstMpeg2Picture ** prev_picture_ptr,
182 GstMpeg2Picture ** next_picture_ptr);
184 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstMpeg2Picture, gst_mpeg2_picture_unref)
188 #endif /* __GST_MPEG2_PICTURE_H__ */