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_DECODER_H__
22 #define __GST_MPEG2_DECODER_H__
24 #include <gst/codecs/codecs-prelude.h>
26 #include <gst/video/video.h>
27 #include <gst/codecparsers/gstmpegvideoparser.h>
28 #include <gst/codecs/gstmpeg2picture.h>
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))
39 typedef struct _GstMpeg2Decoder GstMpeg2Decoder;
40 typedef struct _GstMpeg2DecoderClass GstMpeg2DecoderClass;
41 typedef struct _GstMpeg2DecoderPrivate GstMpeg2DecoderPrivate;
46 * The opaque #GstMpeg2Decoder data structure.
50 struct _GstMpeg2Decoder
53 GstVideoDecoder parent;
56 GstVideoCodecState * input_state;
59 GstMpeg2DecoderPrivate *priv;
61 gpointer padding[GST_PADDING_LARGE];
65 * GstMpeg2DecoderClass:
67 struct _GstMpeg2DecoderClass
69 GstVideoDecoderClass parent_class;
72 * GstMpeg2DecoderClass::new_sequence:
73 * @decoder: a #GstMpeg2Decoder
74 * @seq: a #GstMpegVideoSequenceHdr
75 * @seq_ext: a #GstMpegVideoSequenceExt
77 * Notifies subclass of SPS update
81 GstFlowReturn (*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);
88 * GstMpeg2DecoderClass::new_picture:
89 * @decoder: a #GstMpeg2Decoder
90 * @frame: (transfer none): a #GstVideoCodecFrame
91 * @picture: (transfer none): a #GstMpeg2Picture
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()
99 GstFlowReturn (*new_picture) (GstMpeg2Decoder * decoder,
100 GstVideoCodecFrame * frame,
101 GstMpeg2Picture * picture);
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
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()
115 GstFlowReturn (*new_field_picture) (GstMpeg2Decoder * decoder,
116 const GstMpeg2Picture * first_field,
117 GstMpeg2Picture * second_field);
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
127 * Optional. Called per one #GstMpeg2Picture to notify subclass to prepare
128 * decoding process for the #GstMpeg2Picture
132 GstFlowReturn (*start_picture) (GstMpeg2Decoder * decoder,
133 GstMpeg2Picture * picture,
134 GstMpeg2Slice * slice,
135 GstMpeg2Picture * prev_picture,
136 GstMpeg2Picture * next_picture);
139 * GstMpeg2DecoderClass::decode_slice:
140 * @decoder: a #GstMpeg2Decoder
141 * @picture: (transfer none): a #GstMpeg2Picture
142 * @slice: (transfer none): a #GstMpeg2Slice
144 * Provides per slice data with parsed slice header and required raw bitstream
145 * for subclass to decode it.
149 GstFlowReturn (*decode_slice) (GstMpeg2Decoder * decoder,
150 GstMpeg2Picture * picture,
151 GstMpeg2Slice * slice);
154 * GstMpeg2DecoderClass::end_picture:
155 * @decoder: a #GstMpeg2Decoder
156 * @picture: (transfer none): a #GstMpeg2Picture
158 * Optional. Called per one #GstMpeg2Picture to notify subclass to finish
159 * decoding process for the #GstMpeg2Picture
163 GstFlowReturn (*end_picture) (GstMpeg2Decoder * decoder,
164 GstMpeg2Picture * picture);
167 * GstMpeg2DecoderClass::output_picture:
168 * @decoder: a #GstMpeg2Decoder
169 * @frame: (transfer full): a #GstVideoCodecFrame
170 * @picture: (transfer full): a #GstMpeg2Picture
172 * Called with a #GstMpeg2Picture which is required to be outputted.
173 * The #GstVideoCodecFrame must be consumed by subclass.
177 GstFlowReturn (*output_picture) (GstMpeg2Decoder * decoder,
178 GstVideoCodecFrame * frame,
179 GstMpeg2Picture * picture);
182 * GstMpeg2DecoderClass::get_preferred_output_delay:
183 * @decoder: a #GstMpeg2Decoder
184 * @is_live: whether upstream is live or not
186 * Optional. Called by baseclass to query whether delaying output is
187 * preferred by subclass or not.
189 * Returns: the number of perferred delayed output frames
193 guint (*get_preferred_output_delay) (GstMpeg2Decoder * decoder,
197 gpointer padding[GST_PADDING_LARGE];
200 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstMpeg2Decoder, gst_object_unref)
203 GType gst_mpeg2_decoder_get_type (void);
207 #endif /* __GST_MPEG2_DECODER_H__ */