codecs: vp9decoder: add support for render delay
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / gst-libs / gst / codecs / gstvp9decoder.h
1 /* GStreamer
2  * Copyright (C) 2019 Seungha Yang <seungha.yang@navercorp.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19
20 #ifndef __GST_VP9_DECODER_H__
21 #define __GST_VP9_DECODER_H__
22
23 #include <gst/codecs/codecs-prelude.h>
24
25 #include <gst/video/video.h>
26 #include <gst/codecs/gstvp9picture.h>
27
28 G_BEGIN_DECLS
29
30 #define GST_TYPE_VP9_DECODER            (gst_vp9_decoder_get_type())
31 #define GST_VP9_DECODER(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VP9_DECODER,GstVp9Decoder))
32 #define GST_VP9_DECODER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VP9_DECODER,GstVp9DecoderClass))
33 #define GST_VP9_DECODER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_VP9_DECODER,GstVp9DecoderClass))
34 #define GST_IS_VP9_DECODER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VP9_DECODER))
35 #define GST_IS_VP9_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VP9_DECODER))
36 #define GST_VP9_DECODER_CAST(obj)       ((GstVP9Decoder*)obj)
37
38 typedef struct _GstVp9Decoder GstVp9Decoder;
39 typedef struct _GstVp9DecoderClass GstVp9DecoderClass;
40 typedef struct _GstVp9DecoderPrivate GstVp9DecoderPrivate;
41
42 /**
43  * GstVp9Decoder:
44  *
45  * The opaque #GstVp9Decoder data structure.
46  */
47 struct _GstVp9Decoder
48 {
49   /*< private >*/
50   GstVideoDecoder parent;
51
52   /*< protected >*/
53   GstVideoCodecState * input_state;
54
55   /*< private >*/
56   GstVp9DecoderPrivate *priv;
57   gpointer padding[GST_PADDING_LARGE];
58 };
59
60 /**
61  * GstVp9DecoderClass:
62  */
63 struct _GstVp9DecoderClass
64 {
65   GstVideoDecoderClass parent_class;
66
67   /**
68    * GstVp9DecoderClass::new_sequence:
69    *
70    * Notifies subclass of video sequence update such as resolution, bitdepth,
71    * profile.
72    *
73    * Since: 1.18
74    */
75   GstFlowReturn   (*new_sequence)      (GstVp9Decoder * decoder,
76                                         const GstVp9FrameHeader *frame_hdr);
77
78   /**
79    * GstVp9DecoderClass::new_picture:
80    * @decoder: a #GstVp9Decoder
81    * @frame: (transfer none): a #GstVideoCodecFrame
82    * @picture: (transfer none): a #GstVp9Picture
83    *
84    * Optional. Called whenever new #GstVp9Picture is created.
85    * Subclass can set implementation specific user data on the #GstVp9Picture
86    * via gst_vp9_picture_set_user_data()
87    *
88    * Since: 1.18
89    */
90   GstFlowReturn   (*new_picture)       (GstVp9Decoder * decoder,
91                                         GstVideoCodecFrame * frame,
92                                         GstVp9Picture * picture);
93
94   /**
95    * GstVp9DecoderClass::duplicate_picture:
96    * @decoder: a #GstVp9Decoder
97    * @frame: (transfer none): a #GstVideoCodecFrame
98    * @picture: (transfer none): a #GstVp9Picture to be duplicated
99    *
100    * Optional. Called to duplicate @picture when show_existing_frame flag is set
101    * in the parsed vp9 frame header. Returned #GstVp9Picture from this method
102    * should hold already decoded picture data corresponding to the @picture,
103    * since the returned #GstVp9Picture from this method will be passed to
104    * the output_picture method immediately without additional decoding process.
105    *
106    * If this method is not implemented by subclass, baseclass will drop
107    * current #GstVideoCodecFrame without additional processing for the current
108    * frame.
109    *
110    * Returns: (transfer full): a #GstVp9Picture or %NULL if failed to duplicate
111    * @picture.
112    *
113    * Since: 1.18
114    */
115   GstVp9Picture * (*duplicate_picture) (GstVp9Decoder * decoder,
116                                         GstVideoCodecFrame * frame,
117                                         GstVp9Picture * picture);
118
119   /**
120    * GstVp9DecoderClass::start_picture:
121    * @decoder: a #GstVp9Decoder
122    * @picture: (transfer none): a #GstVp9Picture
123    *
124    * Optional. Called to notify subclass to prepare decoding process for
125    * @picture
126    *
127    * Since: 1.18
128    */
129   GstFlowReturn   (*start_picture)     (GstVp9Decoder * decoder,
130                                         GstVp9Picture * picture);
131
132   /**
133    * GstVp9DecoderClass::decode_picture:
134    * @decoder: a #GstVp9Decoder
135    * @picture: (transfer none): a #GstVp9Picture to decoder
136    * @dpb: (transfer none): a #GstVp9Dpb
137    *
138    * Called to notify decoding for subclass to decoder given @picture with
139    * given @dpb
140    *
141    * Since: 1.18
142    */
143   GstFlowReturn   (*decode_picture)    (GstVp9Decoder * decoder,
144                                         GstVp9Picture * picture,
145                                         GstVp9Dpb * dpb);
146
147   /**
148    * GstVp9DecoderClass::end_picture:
149    * @decoder: a #GstVp9Decoder
150    * @picture: (transfer none): a #GstVp9Picture
151    *
152    * Optional. Called per one #GstVp9Picture to notify subclass to finish
153    * decoding process for the #GstVp9Picture
154    *
155    * Since: 1.18
156    */
157   GstFlowReturn   (*end_picture)       (GstVp9Decoder * decoder,
158                                         GstVp9Picture * picture);
159
160   /**
161    * GstVp9DecoderClass::output_picture:
162    * @decoder: a #GstVp9Decoder
163    * @frame: (transfer full): a #GstVideoCodecFrame
164    * @picture: (transfer full): a #GstVp9Picture
165    *
166    * Called to notify @picture is ready to be outputted.
167    *
168    * Since: 1.18
169    */
170   GstFlowReturn   (*output_picture)    (GstVp9Decoder * decoder,
171                                         GstVideoCodecFrame * frame,
172                                         GstVp9Picture * picture);
173
174   /**
175    * GstVp9DecoderClass::get_preferred_output_delay:
176    * @decoder: a #GstVp9Decoder
177    * @is_live: whether upstream is live or not
178    *
179    * Optional. Retrieve the preferred output delay from child classes.
180    * controls how many frames to delay when calling
181    * GstVp9DecoderClass::output_picture
182    *
183    * Returns: the number of perferred delayed output frame
184    *
185    * Since: 1.20
186    */
187   guint           (*get_preferred_output_delay)   (GstVp9Decoder * decoder,
188                                                    gboolean is_live);
189
190   /*< private >*/
191   gpointer padding[GST_PADDING_LARGE];
192 };
193
194 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVp9Decoder, gst_object_unref)
195
196 GST_CODECS_API
197 GType gst_vp9_decoder_get_type (void);
198
199 G_END_DECLS
200
201 #endif /* __GST_VP9_DECODER_H__ */