Merging gst-plugins-bad
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / gst-libs / gst / codecs / gstmpeg2decoder.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_DECODER_H__
22 #define __GST_MPEG2_DECODER_H__
23
24 #include <gst/codecs/codecs-prelude.h>
25
26 #include <gst/video/video.h>
27 #include <gst/codecparsers/gstmpegvideoparser.h>
28 #include <gst/codecs/gstmpeg2picture.h>
29
30 G_BEGIN_DECLS
31
32 #define GST_TYPE_MPEG2_DECODER            (gst_mpeg2_decoder_get_type())
33 #define GST_MPEG2_DECODER(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MPEG2_DECODER,GstMpeg2Decoder))
34 #define GST_MPEG2_DECODER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MPEG2_DECODER,GstMpeg2DecoderClass))
35 #define GST_MPEG2_DECODER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_MPEG2_DECODER,GstMpeg2DecoderClass))
36 #define GST_IS_MPEG2_DECODER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MPEG2_DECODER))
37 #define GST_IS_MPEG2_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MPEG2_DECODER))
38
39 typedef struct _GstMpeg2Decoder GstMpeg2Decoder;
40 typedef struct _GstMpeg2DecoderClass GstMpeg2DecoderClass;
41 typedef struct _GstMpeg2DecoderPrivate GstMpeg2DecoderPrivate;
42
43 /**
44  * GstMpeg2Decoder:
45  *
46  * The opaque #GstMpeg2Decoder data structure.
47  *
48  * Since: 1.20
49  */
50 struct _GstMpeg2Decoder
51 {
52   /*< private >*/
53   GstVideoDecoder parent;
54
55   /*< protected >*/
56   GstVideoCodecState * input_state;
57
58   /*< private >*/
59   GstMpeg2DecoderPrivate *priv;
60
61   gpointer padding[GST_PADDING_LARGE];
62 };
63
64 /**
65  * GstMpeg2DecoderClass:
66  */
67 struct _GstMpeg2DecoderClass
68 {
69   GstVideoDecoderClass parent_class;
70
71   /**
72    * GstMpeg2DecoderClass::new_sequence:
73    * @decoder: a #GstMpeg2Decoder
74    * @seq: a #GstMpegVideoSequenceHdr
75    * @seq_ext: a #GstMpegVideoSequenceExt
76    *
77    * Notifies subclass of SPS update
78    *
79    * Since: 1.20
80    */
81   gboolean      (*new_sequence)     (GstMpeg2Decoder * decoder,
82                                      const GstMpegVideoSequenceHdr * seq,
83                                      const GstMpegVideoSequenceExt * seq_ext,
84                                      const GstMpegVideoSequenceDisplayExt * seq_display_ext,
85                                      const GstMpegVideoSequenceScalableExt * seq_scalable_ext);
86
87   /**
88    * GstMpeg2DecoderClass::new_picture:
89    * @decoder: a #GstMpeg2Decoder
90    * @frame: (transfer none): a #GstVideoCodecFrame
91    * @picture: (transfer none): a #GstMpeg2Picture
92    *
93    * Optional. Called whenever new #GstMpeg2Picture is created.
94    * Subclass can set implementation specific user data
95    * on the #GstMpeg2Picture via gst_mpeg2_picture_set_user_data()
96    *
97    * Since: 1.20
98    */
99   gboolean      (*new_picture)      (GstMpeg2Decoder * decoder,
100                                      GstVideoCodecFrame * frame,
101                                      GstMpeg2Picture * picture);
102
103   /**
104    * GstMpeg2DecoderClass::new_field_picture:
105    * @decoder: a #GstMpeg2Decoder
106    * @first_field: (transfer none): the first field #GstMpeg2Picture already decoded
107    * @second_field: (transfer none): a #GstMpeg2Picture for the second field
108    *
109    * Called when a new field picture is created for interlaced field picture.
110    * Subclass can attach implementation specific user data on @second_field via
111    * gst_mpeg2_picture_set_user_data()
112    *
113    * Since: 1.20
114    */
115   gboolean      (*new_field_picture)  (GstMpeg2Decoder * decoder,
116                                        const GstMpeg2Picture * first_field,
117                                        GstMpeg2Picture * second_field);
118
119   /**
120    * GstMpeg2DecoderClass::start_picture:
121    * @decoder: a #GstMpeg2Decoder
122    * @picture: (transfer none): a #GstMpeg2Picture
123    * @slice: (transfer none): a #GstMpeg2Slice
124    * @prev_picture: (transfer none): a #GstMpeg2Picture
125    * @next_picture: (transfer none): a #GstMpeg2Picture
126    *
127    * Optional. Called per one #GstMpeg2Picture to notify subclass to prepare
128    * decoding process for the #GstMpeg2Picture
129    *
130    * Since: 1.20
131    */
132   gboolean      (*start_picture)    (GstMpeg2Decoder * decoder,
133                                      GstMpeg2Picture * picture,
134                                      GstMpeg2Slice * slice,
135                                      GstMpeg2Picture * prev_picture,
136                                      GstMpeg2Picture * next_picture);
137
138   /**
139    * GstMpeg2DecoderClass::decode_slice:
140    * @decoder: a #GstMpeg2Decoder
141    * @picture: (transfer none): a #GstMpeg2Picture
142    * @slice: (transfer none): a #GstMpeg2Slice
143    *
144    * Provides per slice data with parsed slice header and required raw bitstream
145    * for subclass to decode it.
146    *
147    * Since: 1.20
148    */
149   gboolean      (*decode_slice)     (GstMpeg2Decoder * decoder,
150                                      GstMpeg2Picture * picture,
151                                      GstMpeg2Slice * slice);
152
153   /**
154    * GstMpeg2DecoderClass::end_picture:
155    * @decoder: a #GstMpeg2Decoder
156    * @picture: (transfer none): a #GstMpeg2Picture
157    *
158    * Optional. Called per one #GstMpeg2Picture to notify subclass to finish
159    * decoding process for the #GstMpeg2Picture
160    *
161    * Since: 1.20
162    */
163   gboolean      (*end_picture)      (GstMpeg2Decoder * decoder,
164                                      GstMpeg2Picture * picture);
165
166   /**
167    * GstMpeg2DecoderClass::output_picture:
168    * @decoder: a #GstMpeg2Decoder
169    * @frame: (transfer full): a #GstVideoCodecFrame
170    * @picture: (transfer full): a #GstMpeg2Picture
171    *
172    * Called with a #GstMpeg2Picture which is required to be outputted.
173    * The #GstVideoCodecFrame must be consumed by subclass.
174    *
175    * Since: 1.20
176    */
177   GstFlowReturn (*output_picture)   (GstMpeg2Decoder * decoder,
178                                      GstVideoCodecFrame * frame,
179                                      GstMpeg2Picture * picture);
180
181   /*< private >*/
182   gpointer padding[GST_PADDING_LARGE];
183 };
184
185 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstMpeg2Decoder, gst_object_unref)
186
187 GST_CODECS_API
188 GType gst_mpeg2_decoder_get_type (void);
189
190 G_END_DECLS
191
192 #endif /* __GST_MPEG2_DECODER_H__ */