Move files from gst-plugins-bad into the "subprojects/gst-plugins-bad/" subdir
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / gst-libs / gst / codecs / gstmpeg2picture.h
1 /* GStreamer
2  * Copyright (C) 2020 Intel Corporation
3  *     Author: He Junyan <junyan.he@intel.com>
4  *
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.
9  *
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.
14  *
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.
19  */
20
21 #ifndef __GST_MPEG2_PICTURE_H__
22 #define __GST_MPEG2_PICTURE_H__
23
24 #include <gst/codecs/codecs-prelude.h>
25 #include <gst/codecparsers/gstmpegvideoparser.h>
26 #include <gst/video/video.h>
27
28 G_BEGIN_DECLS
29
30 /**
31  * GST_TYPE_MPEG2_PICTURE:
32  *
33  * Since: 1.20
34  */
35 #define GST_TYPE_MPEG2_PICTURE      (gst_mpeg2_picture_get_type())
36 /**
37  * GST_IS_MPEG2_PICTURE:
38  *
39  * Since: 1.20
40  */
41 #define GST_IS_MPEG2_PICTURE(obj)   (GST_IS_MINI_OBJECT_TYPE(obj, GST_TYPE_MPEG2_PICTURE))
42 /**
43  * GST_MPEG2_PICTURE:
44  *
45  * Since: 1.20
46  */
47 #define GST_MPEG2_PICTURE(obj)      ((GstMpeg2Picture *)obj)
48
49 typedef struct _GstMpeg2Slice GstMpeg2Slice;
50 typedef struct _GstMpeg2Picture GstMpeg2Picture;
51
52 /**
53  * GstMpeg2Slice:
54  *
55  * Since: 1.20
56  */
57 struct _GstMpeg2Slice
58 {
59   /*< private >*/
60   GstMpegVideoQuantMatrixExt *quant_matrix;   /* The parameter set */
61   GstMpegVideoPictureHdr *pic_hdr;
62   GstMpegVideoPictureExt *pic_ext;
63
64   GstMpegVideoSliceHdr header;
65
66   /* parsed video packet (doesn't take ownership of raw data) */
67   GstMpegVideoPacket packet;
68 };
69
70 /**
71  * GstMpeg2Picture:
72  *
73  * Since: 1.20
74  */
75 struct _GstMpeg2Picture
76 {
77   /*< private >*/
78   GstMiniObject parent;
79
80   /* From GstVideoCodecFrame */
81   guint32 system_frame_number;
82   gboolean needed_for_output;
83   /* For interlaced streams */
84   GstMpeg2Picture *first_field;
85
86   GstVideoBufferFlags buffer_flags;
87
88   gint pic_order_cnt;
89   gint tsn;
90   GstMpegVideoPictureStructure structure;
91   GstMpegVideoPictureType type;
92
93   gpointer user_data;
94   GDestroyNotify notify;
95 };
96
97 /**
98  * GST_MPEG2_PICTURE_IS_REF:
99  * @picture: a #GstMpeg2Picture
100  *
101  * Check whether @picture's type is I or P
102  *
103  * Since: 1.20
104  */
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)
108
109 GST_CODECS_API
110 GType gst_mpeg2_picture_get_type (void);
111
112 GST_CODECS_API
113 GstMpeg2Picture * gst_mpeg2_picture_new (void);
114
115 static inline GstMpeg2Picture *
116 gst_mpeg2_picture_ref (GstMpeg2Picture * picture)
117 {
118   return (GstMpeg2Picture *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (picture));
119 }
120
121 static inline void
122 gst_mpeg2_picture_unref (GstMpeg2Picture * picture)
123 {
124   gst_mini_object_unref (GST_MINI_OBJECT_CAST (picture));
125 }
126
127 static inline gboolean
128 gst_mpeg2_picture_replace (GstMpeg2Picture ** old_picture,
129     GstMpeg2Picture * new_picture)
130 {
131   return gst_mini_object_replace ((GstMiniObject **) old_picture,
132       (GstMiniObject *) new_picture);
133 }
134
135 static inline void
136 gst_mpeg2_picture_clear (GstMpeg2Picture ** picture)
137 {
138   if (picture && *picture) {
139     gst_mpeg2_picture_unref (*picture);
140     *picture = NULL;
141   }
142 }
143
144 GST_CODECS_API
145 void gst_mpeg2_picture_set_user_data (GstMpeg2Picture * picture,
146                                       gpointer user_data,
147                                       GDestroyNotify notify);
148
149 GST_CODECS_API
150 gpointer gst_mpeg2_picture_get_user_data (GstMpeg2Picture * picture);
151
152
153 /**
154  * GstMpeg2Dpb:
155  *
156  * Since: 1.20
157  */
158 typedef struct _GstMpeg2Dpb GstMpeg2Dpb;
159
160 GST_CODECS_API
161 GstMpeg2Dpb * gst_mpeg2_dpb_new       (void);
162
163 GST_CODECS_API
164 void gst_mpeg2_dpb_free               (GstMpeg2Dpb * dpb);
165
166 GST_CODECS_API
167 void gst_mpeg2_dpb_clear              (GstMpeg2Dpb * dpb);
168
169 GST_CODECS_API
170 void gst_mpeg2_dpb_add                (GstMpeg2Dpb * dpb,
171                                        GstMpeg2Picture * picture);
172 GST_CODECS_API
173 GstMpeg2Picture * gst_mpeg2_dpb_bump  (GstMpeg2Dpb * dpb);
174
175 GST_CODECS_API
176 gboolean gst_mpeg2_dpb_need_bump      (GstMpeg2Dpb * dpb);
177
178 GST_CODECS_API
179 void gst_mpeg2_dpb_get_neighbours     (GstMpeg2Dpb * dpb,
180                                        GstMpeg2Picture * picture,
181                                        GstMpeg2Picture ** prev_picture_ptr,
182                                        GstMpeg2Picture ** next_picture_ptr);
183
184 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstMpeg2Picture, gst_mpeg2_picture_unref)
185
186 G_END_DECLS
187
188 #endif /* __GST_MPEG2_PICTURE_H__ */